:root {
  color-scheme: light;
  --bg: #f7efe3;
  --bg-accent: #f0c49b;
  --ink: #1f1b16;
  --muted: #6f655b;
  --card: rgba(255, 255, 255, 0.78);
  --primary: #e65f42;
  --primary-dark: #c4482f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  font-family: "Space Grotesk", "IBM Plex Sans", "Trebuchet MS", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 1200px at 20% -10%, #fff7ec 0%, transparent 60%),
    radial-gradient(900px 900px at 110% 10%, #ffe0ba 0%, transparent 50%),
    linear-gradient(140deg, var(--bg) 20%, var(--bg-accent) 100%);
}

.lotto {
  width: min(520px, 90vw);
  padding: 36px 36px 32px;
  border-radius: 28px;
  background: var(--card);
  backdrop-filter: blur(12px);
  box-shadow: 0 30px 60px rgba(39, 24, 9, 0.18);
  text-align: center;
  animation: rise 0.7s ease-out both;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 18px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  color: var(--primary-dark);
  border: 1px solid rgba(230, 95, 66, 0.35);
  background: rgba(255, 255, 255, 0.8);
  margin-bottom: 18px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.nav-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(230, 95, 66, 0.18);
}

.saju {
  width: min(760px, 92vw);
  padding: 36px 36px 32px;
  border-radius: 28px;
  background: var(--card);
  backdrop-filter: blur(12px);
  box-shadow: 0 30px 60px rgba(39, 24, 9, 0.18);
  text-align: left;
  animation: rise 0.7s ease-out both;
}

.saju header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.saju h1 {
  font-family: "Fraunces", "Palatino Linotype", "Book Antiqua", serif;
  font-size: clamp(2rem, 2.4vw, 2.6rem);
  margin: 0 0 8px;
  letter-spacing: -0.03em;
}

.saju p {
  margin: 0 0 14px;
  color: var(--muted);
}

.saju form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.saju label {
  font-weight: 600;
  display: block;
  margin-bottom: 6px;
}

.saju input,
.saju select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(31, 27, 22, 0.12);
  font-size: 1rem;
}

.saju .grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.saju .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.saju .status {
  font-size: 0.95rem;
  color: var(--muted);
}

.saju .status.error {
  color: #c23a2d;
  font-weight: 600;
}

.saju .inline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.saju .inline input {
  width: auto;
}

.saju .result {
  margin-top: 24px;
  padding: 20px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(31, 27, 22, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
}

.saju .result h2 {
  margin: 0 0 8px;
  font-size: 1.2rem;
}

.details-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  margin: 18px 0;
}

.detail-card {
  padding: 14px;
  border-radius: 16px;
  background: rgba(247, 239, 227, 0.65);
  border: 1px solid rgba(31, 27, 22, 0.06);
}

.detail-card h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.detail-list {
  display: grid;
  gap: 8px;
  font-size: 0.95rem;
  color: var(--muted);
}

.detail-list strong {
  color: var(--ink);
}

.bazi-table {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.bazi-row {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  padding: 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(31, 27, 22, 0.06);
  font-size: 0.95rem;
}

.bazi-cell {
  font-weight: 600;
  color: var(--ink);
}

.hexagrams {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin: 18px 0 8px;
}

.hexagram-card {
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(31, 27, 22, 0.08);
  box-shadow: 0 10px 20px rgba(39, 24, 9, 0.08);
}

.hexagram-card h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.hexagram-lines {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.hex-line {
  height: 10px;
  border-radius: 999px;
  background: var(--ink);
}

.hex-line.yin {
  background: linear-gradient(
    to right,
    var(--ink) 0%,
    var(--ink) 42%,
    transparent 42%,
    transparent 58%,
    var(--ink) 58%,
    var(--ink) 100%
  );
}

.hex-line.moving {
  box-shadow: 0 0 0 2px rgba(230, 95, 66, 0.45);
}

.method {
  margin-top: 18px;
  font-size: 0.9rem;
  color: var(--muted);
}

.saju .pill {
  display: inline-flex;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(230, 95, 66, 0.15);
  color: var(--primary-dark);
  font-weight: 600;
  font-size: 0.85rem;
  margin-right: 8px;
  margin-bottom: 8px;
}

.saju .sections {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-top: 12px;
}

.saju .section {
  border-radius: 16px;
  padding: 14px;
  background: rgba(247, 239, 227, 0.6);
  border: 1px solid rgba(31, 27, 22, 0.06);
}

.saju .section h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.lang-switch {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 12px;
}

.lang-switch label {
  font-weight: 600;
}

.lang-switch select {
  border-radius: 999px;
  border: 1px solid rgba(31, 27, 22, 0.15);
  padding: 6px 12px;
  background: #fff;
  font-weight: 600;
  color: var(--ink);
}

.lotto h1 {
  font-family: "Fraunces", "Palatino Linotype", "Book Antiqua", serif;
  font-size: clamp(2rem, 2.4vw, 2.6rem);
  margin: 0 0 10px;
  letter-spacing: -0.03em;
}

.lotto p {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 0.98rem;
}

#generate {
  border: none;
  padding: 14px 28px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 1rem;
  color: #fff;
  background: linear-gradient(120deg, var(--primary), #ff8b5e);
  box-shadow: 0 14px 24px rgba(230, 95, 66, 0.35);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#generate:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 30px rgba(230, 95, 66, 0.45);
}

#generate:active {
  transform: translateY(0);
  background: linear-gradient(120deg, var(--primary-dark), #e56b41);
}

#numbers {
  margin-top: 26px;
  min-height: 58px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.ball {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-weight: 700;
  background: #fff;
  border: 2px solid #f2c79d;
  box-shadow: 0 12px 24px rgba(39, 24, 9, 0.14);
  animation: pop 0.4s ease-out both;
}

.ball:nth-child(1) { animation-delay: 0.02s; }
.ball:nth-child(2) { animation-delay: 0.06s; }
.ball:nth-child(3) { animation-delay: 0.1s; }
.ball:nth-child(4) { animation-delay: 0.14s; }
.ball:nth-child(5) { animation-delay: 0.18s; }
.ball:nth-child(6) { animation-delay: 0.22s; }

@keyframes rise {
  from {
    transform: translateY(24px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes pop {
  from {
    transform: scale(0.6);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@media (max-width: 540px) {
  .lotto {
    padding: 28px 24px;
  }

  .saju {
    padding: 28px 24px;
  }

  #generate {
    width: 100%;
  }

  .ball {
    width: 46px;
    height: 46px;
    font-size: 0.95rem;
  }
}
