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

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Helvetica Neue", Roboto, sans-serif;
  background: #e8e8e8;
  color: #1c1c1e;
  padding: 24px 16px;
  min-height: 100vh;
}

/* ── Section header ─────────────────────────────────── */
.section-header {
  max-width: 1280px;
  margin: 0 auto 24px;
}

h1 {
  font-size: 2rem;
  font-style: italic;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 10px;
}

.section-desc {
  font-size: 1rem;
  color: #3a3a3c;
  line-height: 1.6;
  max-width: 680px;
}

/* ── Card grid ──────────────────────────────────────── */
.cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  max-width: 1280px;
  margin: 0 auto;
}

/* ── Card ───────────────────────────────────────────── */
.card {
  background: #ffffff;
  border-radius: 20px;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── Card left: name + image ────────────────────────── */
.card-left {
  display: flex;
  flex-direction: row; /* mobile: img-left, name-right via order */
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.card-name {
  font-size: 1.5rem;
  font-weight: 600;
  color: #1c1c1e;
  line-height: 1;
  order: 2; /* name on right in mobile row */
}

.card-face {
  flex-shrink: 0;
  order: 1; /* image on left in mobile row */
}

/* ── Card content ───────────────────────────────────── */
.card-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card-alg {
  font-size: 1.05rem;
  font-weight: 500;
  color: #1c1c1e;
  line-height: 1.55;
}

.card-desc {
  font-size: 0.875rem;
  font-weight: 600;
  color: #1c1c1e;
  line-height: 1.5;
}

.card-tip {
  font-size: 0.82rem;
  font-style: italic;
  color: #6e6e73;
  line-height: 1.55;
}

/* ── Card id: name + fraction stacked ──────────────── */
.card-id {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  order: 2; /* mobile: right, matching .card-name */
}

.card-count {
  font-size: 0.85rem;
  font-style: italic;
  color: #6e6e73;
  line-height: 1;
}

/* ── Spacing between sections ───────────────────────── */
.cards + .section-header {
  margin-top: 48px;
}

/* ── Tablet: 700px+ ─────────────────────────────────── */
@media (min-width: 700px) {
  body {
    padding: 32px 24px;
  }

  .card {
    flex-direction: row;
    align-items: flex-start;
    gap: 20px;
    padding: 20px 24px;
  }

  .card-left {
    flex-direction: row;
    align-items: center;
    gap: 12px;
    min-width: 180px;
  }

  /* restore natural order: name left, image right */
  .card-name {
    order: 1;
    font-size: 1.8rem;
  }

  .card-id {
    order: 1;
  }

  .card-face {
    order: 2;
  }

  .card-content {
    flex: 1;
    gap: 10px;
  }

  .card-alg {
    font-size: 1.1rem;
  }

  .card-desc {
    font-size: 0.9rem;
  }

  .card-tip {
    font-size: 0.85rem;
  }
}

/* ── Desktop: 1024px+ — 2-column grid ──────────────── */
@media (min-width: 1024px) {
  body {
    padding: 44px 48px;
  }

  h1 {
    font-size: 2.4rem;
  }

  .cards {
    grid-template-columns: 1fr 1fr;
    gap: 18px;
  }

  .card-left {
    min-width: 170px;
  }

  .card-name {
    font-size: 1.8rem;
  }
}
