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

:root {
  --bg-gradient: linear-gradient(160deg, #0f172a 0%, #1e293b 45%, #312e81 100%);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-label: #cbd5e1;
  --container-bg: rgba(15, 23, 42, 0.85);
  --container-border: rgba(148, 163, 184, 0.2);
  --container-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --input-bg: #1e293b;
  --input-border: rgba(148, 163, 184, 0.35);
  --row-bg: rgba(30, 41, 59, 0.75);
  --row-border: rgba(148, 163, 184, 0.12);
  --empty-border: rgba(148, 163, 184, 0.25);
  --theme-toggle-bg: rgba(30, 41, 59, 0.9);
  --theme-toggle-border: rgba(148, 163, 184, 0.25);
  --theme-toggle-hover: rgba(51, 65, 85, 0.95);
  --header-bg: rgba(15, 23, 42, 0.92);
  --footer-bg: rgba(15, 23, 42, 0.75);
  --accent: #f59e0b;
  --link: #93c5fd;
}

[data-theme="light"] {
  --bg-gradient: linear-gradient(160deg, #f8fafc 0%, #e2e8f0 45%, #dbeafe 100%);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-label: #334155;
  --container-bg: rgba(255, 255, 255, 0.92);
  --container-border: rgba(148, 163, 184, 0.35);
  --container-shadow: 0 24px 60px rgba(15, 23, 42, 0.12);
  --input-bg: #ffffff;
  --input-border: rgba(148, 163, 184, 0.45);
  --row-bg: rgba(241, 245, 249, 0.95);
  --row-border: rgba(148, 163, 184, 0.25);
  --empty-border: rgba(148, 163, 184, 0.35);
  --theme-toggle-bg: rgba(241, 245, 249, 0.95);
  --theme-toggle-border: rgba(148, 163, 184, 0.35);
  --theme-toggle-hover: rgba(226, 232, 240, 0.98);
  --header-bg: rgba(255, 255, 255, 0.95);
  --footer-bg: rgba(241, 245, 249, 0.95);
  --link: #2563eb;
}

body {
  min-height: 100vh;
  font-family: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  background: var(--bg-gradient);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background 0.3s ease, color 0.3s ease;
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  border-bottom: 1px solid var(--container-border);
  backdrop-filter: blur(12px);
}

.site-header-inner,
.site-footer-inner,
.page-wrap {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px;
}

.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
}

.site-logo {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

.site-logo:hover {
  text-decoration: none;
  color: var(--accent);
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  justify-content: flex-end;
}

.site-nav a {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
}

.site-nav a.active,
.site-nav a:hover {
  color: var(--accent);
  text-decoration: none;
}

.page-wrap {
  padding-top: 28px;
  padding-bottom: 40px;
}

.container {
  position: relative;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  background: var(--container-bg);
  border: 1px solid var(--container-border);
  border-radius: 24px;
  padding: 32px 28px;
  box-shadow: var(--container-shadow);
  backdrop-filter: blur(12px);
  transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.theme-toggle {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border: 1px solid var(--theme-toggle-border);
  border-radius: 50%;
  background: var(--theme-toggle-bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.15s ease;
}

.theme-toggle:hover {
  background: var(--theme-toggle-hover);
  transform: scale(1.05);
}

.theme-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.theme-icon-light {
  display: none;
}

[data-theme="light"] .theme-icon-dark {
  display: none;
}

[data-theme="light"] .theme-icon-light {
  display: inline;
}

h1 {
  font-size: 1.75rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 8px;
}

.subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 28px;
}

.controls {
  display: flex;
  gap: 12px;
  margin-bottom: 28px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  font-size: 0.85rem;
  color: var(--text-label);
}

select {
  appearance: none;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text-primary);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.generate-btn {
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 16px;
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  margin-bottom: 24px;
}

.generate-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(245, 158, 11, 0.35);
}

.generate-btn:active {
  transform: translateY(0);
}

.results {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--row-bg);
  border-radius: 16px;
  border: 1px solid var(--row-border);
  transition: background 0.3s ease, border-color 0.3s ease;
}

.row-label {
  min-width: 28px;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

.balls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  flex: 1;
}

.ball {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  box-shadow:
    inset 0 -4px 8px rgba(0, 0, 0, 0.18),
    inset 0 4px 8px rgba(255, 255, 255, 0.25),
    0 4px 10px rgba(0, 0, 0, 0.2);
  animation: pop 0.35s ease backwards;
}

.ball:nth-child(1) { animation-delay: 0.05s; }
.ball:nth-child(2) { animation-delay: 0.1s; }
.ball:nth-child(3) { animation-delay: 0.15s; }
.ball:nth-child(4) { animation-delay: 0.2s; }
.ball:nth-child(5) { animation-delay: 0.25s; }
.ball:nth-child(6) { animation-delay: 0.3s; }

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

.ball.yellow { background: radial-gradient(circle at 30% 30%, #ffe066, #fbc400); color: #5c4a00; }
.ball.blue { background: radial-gradient(circle at 30% 30%, #9ee0ff, #69c8f2); color: #0c3d5c; }
.ball.red { background: radial-gradient(circle at 30% 30%, #ffb0b0, #ff7272); color: #6b1010; }
.ball.gray { background: radial-gradient(circle at 30% 30%, #d4d4d4, #aaa); color: #333; }
.ball.green { background: radial-gradient(circle at 30% 30%, #d4f07a, #b0d840); color: #3a5200; }

.empty {
  text-align: center;
  color: var(--text-muted);
  padding: 32px 12px;
  border: 1px dashed var(--empty-border);
  border-radius: 16px;
  line-height: 1.6;
}

.ad-container {
  width: 100%;
  overflow: hidden;
  border-radius: 12px;
  background: var(--row-bg);
  border: 1px solid var(--row-border);
  margin: 24px 0;
  min-height: 90px;
}

.ad-label {
  display: block;
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 6px 0 0;
}

.content-section {
  margin-top: 36px;
  background: var(--container-bg);
  border: 1px solid var(--container-border);
  border-radius: 20px;
  padding: 28px 24px;
  box-shadow: var(--container-shadow);
}

.content-section h2 {
  font-size: 1.25rem;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.content-section h3 {
  font-size: 1.05rem;
  margin: 20px 0 8px;
  color: var(--text-primary);
}

.content-section p,
.content-section li {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.content-section ul,
.content-section ol {
  padding-left: 1.25rem;
  margin: 10px 0 16px;
}

.content-section li + li {
  margin-top: 6px;
}

.content-page {
  background: var(--container-bg);
  border: 1px solid var(--container-border);
  border-radius: 20px;
  padding: 32px 28px;
  box-shadow: var(--container-shadow);
}

.content-page h1 {
  text-align: left;
  font-size: 1.8rem;
  margin-bottom: 10px;
}

.content-page .lead {
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.content-page h2 {
  font-size: 1.2rem;
  margin: 28px 0 10px;
}

.content-page p,
.content-page li {
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.content-page ul,
.content-page ol {
  padding-left: 1.25rem;
  margin-bottom: 16px;
}

.faq-item {
  border-top: 1px solid var(--row-border);
  padding-top: 16px;
  margin-top: 16px;
}

.faq-item:first-of-type {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

.site-footer {
  margin-top: 40px;
  background: var(--footer-bg);
  border-top: 1px solid var(--container-border);
  padding: 28px 0;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin-bottom: 12px;
}

.footer-links a {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.footer-note {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.disclaimer-box {
  background: var(--row-bg);
  border: 1px solid var(--row-border);
  border-radius: 12px;
  padding: 16px;
  margin: 20px 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

@media (max-width: 640px) {
  .site-header-inner {
    flex-direction: column;
    align-items: flex-start;
    padding-top: 14px;
    padding-bottom: 14px;
  }

  .site-nav {
    justify-content: flex-start;
  }

  .container,
  .content-page,
  .content-section {
    padding: 24px 18px;
  }
}
