:root {
  --primary: #007bff;
  --primary-soft: #e7f1ff;
  --primary-hover: #0056b3;
  --success: #28a745;
  --danger: #dc3545;
  --warning: #ffc107;
  
  --bg-app: #f8f9fa;
  --bg-card: #ffffff;
  --text-main: #212529;
  --text-sub: #6c757d;
  --border: #dee2e6;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  
  --ball-size: 38px;
  --app-gap: 20px;
}

[data-theme="dark"] {
  --bg-app: #121212;
  --bg-card: #1e1e1e;
  --text-main: #f8f9fa;
  --text-sub: #adb5bd;
  --border: #2d2d2d;
  --shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  --primary-soft: #1a2635;
}

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

body {
  font-family: 'Pretendard Variable', Pretendard, -apple-system, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.6;
  display: flex;
  justify-content: center;
  padding: 40px 15px;
  transition: background-color 0.3s;
}

.app-container {
  max-width: 500px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--app-gap);
}

header { text-align: center; }
.brand { margin-bottom: 15px; }
header h1 { margin-bottom: 8px; line-height: 1; }
.logo-img { height: 125px; width: auto; vertical-align: middle; }

.countdown-badge {
  display: inline-block;
  padding: 5px 15px;
  background: var(--danger);
  color: white;
  border-radius: 30px;
  font-size: 0.8rem;
  font-weight: 700;
  box-shadow: 0 4px 10px rgba(220, 53, 69, 0.2);
}

/* 추출 버튼 영역 */
.action-area {
  margin-top: 10px;
  margin-bottom: 30px; /* 설정 카드와 여백 추가 */
  display: flex;
  justify-content: center;
}

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.card-header-row .card-title {
  margin-bottom: 0;
}

.info-banner {
  background: var(--primary-soft);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 15px;
  border: 1px dashed var(--primary);
  color: var(--text-main);
  text-align: center;
}

.text-btn.danger {
  color: var(--danger);
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 18px;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Latest Win Card */
.latest-card {
  background: linear-gradient(135deg, #007bff, #00c6ff);
  color: white;
  padding: 24px;
  border-radius: 20px;
  box-shadow: 0 8px 20px rgba(0, 123, 255, 0.15);
  text-align: center;
}

.latest-win-balls {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 15px;
  flex-wrap: wrap;
}

/* Filters */
.filter-tabs {
  display: flex;
  background: var(--bg-app);
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 15px;
}

.tab-btn {
  flex: 1;
  padding: 10px;
  border: none;
  background: none;
  color: var(--text-sub);
  font-weight: 700;
  cursor: pointer;
  border-radius: 10px;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.tab-btn.active {
  background: var(--bg-card);
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.number-grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 6px;
  margin-bottom: 15px;
}

.num-chip {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.num-chip:hover { border-color: var(--primary); color: var(--primary); }
.num-chip.fixed { background: var(--primary); color: white; border-color: var(--primary); }
.num-chip.excluded { background: var(--danger); color: white; border-color: var(--danger); }

/* Buttons */
.main-btn {
  width: 100%;
  padding: 20px;
  border-radius: 18px;
  border: none;
  background: var(--primary);
  color: white;
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 8px 20px rgba(0, 123, 255, 0.25);
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.main-btn:hover { background: var(--primary-hover); transform: translateY(-3px); box-shadow: 0 12px 25px rgba(0, 123, 255, 0.3); }
.main-btn:active { transform: translateY(0); }

.utility-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding-top: 10px; padding-bottom: 5px;}

.sub-btn {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-main);
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9rem;
}

.sub-btn:hover { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.sub-btn.secondary { background: var(--primary-soft); border-color: transparent; color: var(--primary); }

.text-btn { border: none; background: none; color: var(--primary); font-weight: 700; font-size: 0.8rem; cursor: pointer; }

/* Results Animation */
.lotto-row {
  background: var(--bg-card);
  padding: 20px;
  border-radius: 20px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  animation: revealRow 0.6s cubic-bezier(0.23, 1, 0.32, 1) both;
}

@keyframes revealRow {
  0% { opacity: 0; transform: scale(0.9) translateY(20px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

.balls-container { display: flex; gap: 8px; align-items: center; }

/* Balls styling */
.ball {
  width: var(--ball-size); height: var(--ball-size);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 800; font-size: 0.95rem;
  box-shadow: inset -3px -3px 6px rgba(0,0,0,0.2);
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
  animation: popBall 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

@keyframes popBall {
  0% { transform: scale(0) rotate(-180deg); }
  100% { transform: scale(1) rotate(0); }
}

.ball-yellow { background: radial-gradient(circle at 30% 30%, #ffdf00, #fbc400); }
.ball-blue { background: radial-gradient(circle at 30% 30%, #87ceeb, #69c8f2); }
.ball-red { background: radial-gradient(circle at 30% 30%, #ff9a9e, #ff7272); }
.ball-gray { background: radial-gradient(circle at 30% 30%, #cccccc, #aaa); }
.ball-green { background: radial-gradient(circle at 30% 30%, #d4fc79, #b0d840); }

/* Analysis Badges */
.analysis-row { display: flex; gap: 5px; }
.analysis-badge { padding: 3px 10px; background: var(--bg-app); border-radius: 8px; font-size: 0.7rem; font-weight: 700; color: var(--text-sub); }

.saved-list { max-height: 250px; overflow-y: auto; padding-right: 5px; }
.saved-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }

/* 포스팅 섹션 스타일 */
.posts-card { margin-top: 10px; }
.post-list { display: flex; flex-direction: column; gap: 10px; }
.post-item { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--bg-app); transition: all 0.2s; }

.post-header { 
  padding: 15px; 
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
  cursor: pointer; 
  background: var(--bg-card);
  user-select: none;
}
.post-header:hover { background: var(--primary-soft); }

.post-title { font-size: 0.9rem; font-weight: 700; color: var(--text-main); line-height: 1.4; flex: 1; padding-right: 10px; }
.post-arrow { font-size: 0.7rem; color: var(--text-sub); transition: transform 0.3s; }

.post-body { 
  max-height: 0; 
  overflow: hidden; 
  transition: max-height 0.4s cubic-bezier(0, 1, 0, 1); 
  background: var(--bg-card);
}
.post-item.active .post-body { max-height: 1000px; transition: max-height 0.6s ease-in; border-top: 1px solid var(--border); }
.post-item.active .post-arrow { transform: rotate(180deg); color: var(--primary); }

.post-content { padding: 20px; font-size: 0.85rem; color: var(--text-main); }
.post-intro { margin-bottom: 15px; color: var(--text-sub); line-height: 1.6; }
.post-sub { font-size: 0.9rem; margin: 15px 0 10px; color: var(--primary); }
.post-content ul { padding-left: 20px; margin-bottom: 15px; }
.post-content li { margin-bottom: 10px; line-height: 1.5; }
.post-tip { background: var(--bg-app); padding: 15px; border-radius: 10px; border-left: 4px solid var(--primary); margin-top: 15px; }
.post-tip strong { display: block; margin-bottom: 5px; color: var(--primary); }
.post-tip small { display: block; margin-top: 8px; color: var(--text-sub); font-style: italic; }
.post-footer { margin-top: 20px; padding-top: 15px; border-top: 1px dashed var(--border); text-align: center; color: var(--primary); font-weight: 700; }

.theme-btn {
  position: fixed; top: 20px; right: 20px; width: 44px; height: 44px;
  border-radius: 50%; border: none; background: var(--bg-card);
  box-shadow: 0 4px 15px rgba(0,0,0,0.1); cursor: pointer; z-index: 3000; font-size: 1.2rem;
}

/* Footer */
footer {
  text-align: center;
  padding: 40px 20px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  margin-top: 20px;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 15px;
}

.footer-links a {
  font-size: 0.8rem;
  color: var(--text-sub);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s;
}

.footer-links a:hover {
  color: var(--primary);
}

.copyright {
  font-size: 0.8rem;
  color: var(--text-sub);
  margin-bottom: 15px;
}

.disclaimer {
  max-width: 450px;
  margin: 0 auto;
  line-height: 1.4;
  color: var(--text-sub);
  font-size: 0.7rem;
  opacity: 0.8;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 4000;
  backdrop-filter: blur(4px);
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: var(--bg-card);
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
  border: 1px solid var(--border);
}

.modal-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-sub);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text-main);
}

.modal-body h4 {
  margin: 15px 0 8px;
  color: var(--primary);
}

.modal-body p {
  margin-bottom: 10px;
}

.modal-body ul {
  padding-left: 20px;
  margin-bottom: 10px;
}

/* FAQ Section */
.faq-card { margin-top: 10px; }
.faq-list { display: flex; flex-direction: column; gap: 15px; }
.faq-item { padding-bottom: 15px; border-bottom: 1px solid var(--border); }
.faq-item:last-child { border-bottom: none; padding-bottom: 0; }
.faq-q { font-size: 0.9rem; color: var(--primary); margin-bottom: 5px; }
.faq-a { font-size: 0.85rem; color: var(--text-sub); line-height: 1.5; }

@media (max-width: 480px) {
  .number-grid { grid-template-columns: repeat(7, 1fr); }
  .ball { --ball-size: 32px; font-size: 0.85rem; }
  .lotto-row { padding: 15px; }
  .footer-links { gap: 10px; }
  .footer-links a { font-size: 0.75rem; }
}
