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

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  color: #333;
  background-color: #f5f5f5;
  padding: 20px;
}

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

h1 {
  text-align: center;
  margin-bottom: 40px;
  color: #2c3e50;
}

h2 {
  margin-bottom: 15px;
  color: #34495e;
  border-bottom: 2px solid #3498db;
  padding-bottom: 10px;
}

h3 {
  font-size: 0.9em;
  margin-bottom: 10px;
  color: #555;
}

.demo-section {
  background: white;
  padding: 30px;
  margin-bottom: 40px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  scroll-margin-top: 20px;
}

.demo-section p {
  margin-bottom: 20px;
  color: #666;
}

/* フレックスボックスの基本スタイル */
.flex-container {
  display: flex;
  background-color: #f0f0f0;
  padding: 10px;
  border-radius: 4px;
  min-height: 100px;
}

.flex-item {
  background-color: coral;
  color: white;
  padding: 20px;
  margin: 5px;
  border-radius: 4px;
  text-align: center;
  font-weight: bold;
}

/* 1. フレックスボックスの基本 */
.flex-container.basic {
  /* 基本スタイルのみ */
}

/* 2. flex-wrap */
.flex-container.wrap {
  flex-wrap: wrap;
}

.flex-container.wrap .flex-item {
  flex: 1 1 200px;
  min-width: 150px;
}

/* 3. flex プロパティ（割合値） */
.flex-1 {
  flex: 1;
}

.flex-2 {
  flex: 2;
}

/* 4. flex プロパティ（最小サイズ） */
.flex-min-1 {
  flex: 1 150px;
}

.flex-min-2 {
  flex: 2 150px;
}

/* 5. justify-content */
.justify-start {
  justify-content: flex-start;
}

.justify-end {
  justify-content: flex-end;
}

.justify-center {
  justify-content: center;
}

.justify-between {
  justify-content: space-between;
}

.justify-around {
  justify-content: space-around;
}

/* 6. align-items */
.align-stretch {
  align-items: stretch;
}

.align-start {
  align-items: flex-start;
}

.align-end {
  align-items: flex-end;
}

.align-center {
  align-items: center;
}

.flex-item.tall {
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 7. 中央配置の例 */
.center-both {
  justify-content: center;
  align-items: center;
  height: 300px;
}

/* 8. flex-direction */
.direction-row {
  flex-direction: row;
}

.direction-column {
  flex-direction: column;
  height: 200px;
}

/* デモグリッド（複数のデモを並べる） */
.demo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
}

.demo-grid > div {
  background-color: #fafafa;
  padding: 15px;
  border-radius: 4px;
  border: 1px solid #e0e0e0;
}

.demo-grid .flex-container {
  margin-top: 10px;
}

/* グリッドレイアウトの基本スタイル */
.grid-container {
  display: grid;
  background-color: #f0f0f0;
  padding: 10px;
  border-radius: 4px;
}

.grid-item {
  background-color: #3498db;
  color: white;
  padding: 20px;
  border-radius: 4px;
  text-align: center;
  font-weight: bold;
  border: none;
  cursor: pointer;
  transition: background-color 0.3s;
}

.grid-item:hover {
  background-color: #2980b9;
}

.grid-item:active {
  background-color: #21618c;
}

/* 9. グリッドレイアウトの基本 */
.basic-grid {
  grid-template-columns: 200px 200px;
}

/* 10. fr 単位 */
.fr-equal {
  grid-template-columns: 1fr 1fr 1fr;
}

.fr-ratio {
  grid-template-columns: 2fr 1fr 1fr;
}

/* 11. repeat() */
.repeat-grid {
  grid-template-columns: repeat(3, 1fr);
}

/* 12. gap */
.gap-grid {
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
  .demo-grid {
    grid-template-columns: 1fr;
  }

  .flex-container.wrap .flex-item {
    flex: 1 1 100%;
  }

  .basic-grid {
    grid-template-columns: 1fr;
  }

  .fr-equal,
  .fr-ratio,
  .repeat-grid,
  .gap-grid {
    grid-template-columns: 1fr;
  }
}
