/* 로또 번호 생성기 — 와인/버건디 팔레트 (#9F1239) · 행운·복권의 고급스러운 붉은 톤 */

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

:root {
  --brand:       #9F1239;
  --brand-dark:  #701A3A;
  --brand-light: #FBCFE8;
  --brand-alt:   #BE185D;
  --bg:          #FDF2F8;
  --surface:     #FFFFFF;
  --surface2:    #FFF7FB;
  --border:      #F3D4DE;
  --text:        #1A1A1A;
  --text-muted:  #6B7280;
  --accent:      #BE185D;
  --radius:      16px;
  --radius-sm:   10px;
  --shadow:      0 4px 20px rgba(159, 18, 57, .08);
  --shadow-sm:   0 2px 8px rgba(159, 18, 57, .06);
  font-family: "Noto Sans KR", "Inter", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { background: var(--bg); color: var(--text); min-height: 100dvh; overflow-x: hidden; font-size: 16px; line-height: 1.6; }
button { cursor: pointer; border: none; font-family: inherit; background: none; }
a { text-decoration: none; color: inherit; }
input, select, textarea { font-family: inherit; }

.layout-container {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}
@media (max-width: 800px) {
  .layout-container { grid-template-columns: 1fr; padding: 16px 12px 40px; }
  .app-sidebar { display: none; }
}
@media (max-width: 520px) {
  .hero-title { font-size: 22px !important; }
  .hero-desc { font-size: 13px !important; }
}

.ad-container { display: block; width: 100%; text-align: center; }
.top-ad { background: #FFF7FB; padding: 8px 0; border-bottom: 1px solid var(--border); }
.middle-ad { margin: 16px 0; }
.bottom-ad { margin-top: 24px; padding: 16px 0; border-top: 1px solid var(--border); }

/* ========== 헤더 (와인 그라디언트) ========== */
.main-header {
  background: linear-gradient(135deg, #701A3A 0%, #9F1239 55%, #BE185D 100%);
  padding: 18px 16px 30px;
  position: relative; overflow: hidden;
}
.main-header::before { content:''; position:absolute; top:-40px; right:-40px; width:180px; height:180px; border-radius:50%; background: rgba(255,255,255,.09); }
.main-header::after { content:''; position:absolute; bottom:-30px; left:20px; width:110px; height:110px; border-radius:50%; background: rgba(255,255,255,.06); }

.header-inner {
  max-width: 1100px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  position: relative; z-index: 1;
}
.header-logo { display: flex; align-items: center; gap: 12px; }
.header-logo-icon {
  font-size: 30px; background: rgba(255,255,255,.2); border-radius: 12px;
  width: 52px; height: 52px; display: flex; align-items: center; justify-content: center;
}
.header-logo h1 { font-size: 22px; font-weight: 800; color: #fff; letter-spacing: -.5px; }
.header-logo h1 a { color: #fff; }
.header-logo p { font-size: 12px; color: rgba(255,255,255,.85); margin-top: 2px; }

.btn-share {
  font-size: 13px; color: #fff;
  padding: 8px 14px; border-radius: 20px;
  background: rgba(255,255,255,.2); border: 1.5px solid rgba(255,255,255,.4);
  font-weight: 600; position: relative; z-index: 1;
}
.btn-share:hover { background: rgba(255,255,255,.3); }

.header-hero { max-width: 1100px; margin: 18px auto 0; position: relative; z-index: 1; }
.hero-title { font-size: 24px; font-weight: 900; color: #fff; letter-spacing: -.5px; }
.hero-desc { font-size: 14px; color: rgba(255,255,255,.9); margin-top: 6px; line-height: 1.55; }

/* ========== 카드 공통 ========== */
.app-card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; margin-bottom: 16px;
}
.app-card h2 { font-size: 17px; font-weight: 800; padding: 16px 20px 8px; color: #1F2937; }
.card-header {
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px; background: var(--brand-light);
}
.card-header-icon { font-size: 18px; }
.card-header-title { font-size: 15px; font-weight: 700; color: var(--brand-dark); }
.card-body { padding: 22px 20px; }

/* ========== 생성 버튼 ========== */
.control-panel {
  display: flex; gap: 12px; justify-content: center; flex-wrap: wrap;
}
.btn {
  padding: 14px 24px; border-radius: 50px;
  font-size: 15px; font-weight: 800;
  font-family: inherit; transition: transform .15s, box-shadow .15s, background .15s;
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
}
.btn .icon { font-size: 18px; }
.btn-large { padding: 16px 30px; font-size: 17px; flex: 1; min-width: 150px; max-width: 260px; }

.btn-primary {
  background: linear-gradient(135deg, #9F1239 0%, #BE185D 100%);
  color: #fff; box-shadow: 0 6px 18px rgba(159, 18, 57, .35);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(159, 18, 57, .45); }

.btn-secondary {
  background: linear-gradient(135deg, #701A3A 0%, #9F1239 100%);
  color: #fff; box-shadow: 0 6px 18px rgba(112, 26, 58, .3);
}
.btn-secondary:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(112, 26, 58, .4); }

.btn-copy {
  padding: 8px 14px; border-radius: 20px;
  background: var(--brand); color: #fff;
  font-size: 13px; font-weight: 700;
}
.btn-copy:hover { background: var(--brand-dark); }

.btn-text-link {
  background: transparent; color: var(--brand);
  padding: 4px 10px; font-size: 13px; font-weight: 700;
  border-radius: 6px;
}
.btn-text-link:hover { background: var(--brand-light); }

/* ========== 번호 디스플레이 ========== */
.numbers-display { margin-top: 18px; }
.number-set {
  background: linear-gradient(135deg, #FFF7FB 0%, #FDF2F8 100%);
  border: 1px solid var(--brand-light);
  border-radius: var(--radius);
  padding: 18px 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.number-set-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px; padding-bottom: 10px;
  border-bottom: 1px dashed var(--brand-light);
}
.set-label { font-weight: 700; font-size: 14px; color: var(--brand-dark); }

.batch-content { display: flex; flex-direction: column; gap: 10px; }
.batch-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 4px;
  border-bottom: 1px dotted var(--brand-light);
}
.batch-row:last-child { border-bottom: none; }
.batch-label {
  flex-shrink: 0; min-width: 50px;
  font-size: 12px; font-weight: 700; color: var(--text-muted);
}

/* ========== 로또 공 ========== */
.lotto-balls {
  display: flex; gap: 10px; justify-content: center; align-items: center;
  flex-wrap: wrap;
}
.lotto-ball {
  width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 900; color: #fff;
  box-shadow: 0 4px 10px rgba(0, 0, 0, .18);
  position: relative; transition: transform .2s;
  font-family: "Inter", "Noto Sans KR", sans-serif;
  letter-spacing: -.5px;
}
.lotto-ball::before {
  content: '';
  position: absolute; top: 16%; left: 22%;
  width: 28%; height: 28%;
  background: rgba(255, 255, 255, .42);
  border-radius: 50%; filter: blur(2px);
}
.lotto-ball:hover { transform: scale(1.08); }

.balls-small .lotto-ball {
  width: 36px; height: 36px; font-size: 14px;
}

/* 번호 범위별 색상 — 동행복권 공식 색상과 동일한 구분 유지 */
.lotto-ball.range-1 { background: linear-gradient(135deg, #FFC312 0%, #FF9500 100%); }  /* 1-10 노랑 */
.lotto-ball.range-2 { background: linear-gradient(135deg, #3498DB 0%, #2980B9 100%); }  /* 11-20 파랑 */
.lotto-ball.range-3 { background: linear-gradient(135deg, #E74C3C 0%, #C0392B 100%); }  /* 21-30 빨강 */
.lotto-ball.range-4 { background: linear-gradient(135deg, #7F8C8D 0%, #555E60 100%); }  /* 31-40 회색 */
.lotto-ball.range-5 { background: linear-gradient(135deg, #27AE60 0%, #16A085 100%); }  /* 41-45 초록 */

/* ========== 히스토리 ========== */
.history-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px; padding-bottom: 10px;
  border-bottom: 2px solid var(--brand-light);
}
.history-header h2 {
  font-size: 16px; font-weight: 800; color: var(--brand-dark);
  padding: 0;
}
.history-list {
  max-height: 480px; overflow-y: auto;
  padding-right: 2px;
}
.history-item {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  transition: background .15s;
}
.history-item:last-child { border-bottom: none; }
.history-item:hover { background: var(--surface2); }
.history-header-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.history-time {
  font-size: 12px; color: var(--text-muted); font-weight: 500;
}
.history-item .lotto-balls { margin-bottom: 6px; }

.empty-history {
  text-align: center; color: var(--text-muted);
  padding: 32px 16px; font-size: 14px;
  background: var(--surface2);
  border: 1px dashed var(--brand-light);
  border-radius: var(--radius-sm);
  line-height: 1.6;
}

/* ========== 정보 카드 ========== */
.info-card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px;
}
.info-card h2 { font-size: 17px; font-weight: 800; margin-bottom: 14px; color: #1F2937; }

.section-desc { font-size: 13px; color: var(--text-muted); margin: -4px 0 14px; padding: 0 20px; line-height: 1.6; }
.card-body .section-desc { padding: 0; }
.app-card > .section-desc, section.app-card > .section-desc { padding: 0 20px; }

/* ========== FAQ ========== */
.faq-item { border-bottom: 1px solid var(--border); padding: 12px 20px; }
.faq-item:last-child { border-bottom: none; }
.faq-item summary {
  font-size: 14px; font-weight: 700; color: #1F2937;
  cursor: pointer; list-style: none; padding: 4px 0;
  position: relative; padding-right: 24px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: '+'; position: absolute; right: 4px; top: 4px;
  color: var(--brand); font-size: 18px; font-weight: 700;
  transition: transform .2s;
}
.faq-item[open] summary::after { transform: rotate(45deg); }
.faq-item p { font-size: 13px; color: #4B5563; line-height: 1.75; margin-top: 8px; padding-right: 20px; }
.faq-item strong { color: var(--brand-dark); }

/* ========== 랜덤 키워드 ========== */
#random-examples { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 20px; }
#random-examples::before { content: '🔥 자주 찾는 로또 번호 키워드'; grid-column: 1 / -1; font-size: 15px; font-weight: 800; color: #1F2937; margin-bottom: 4px; }
@media (max-width: 520px) { #random-examples { grid-template-columns: 1fr; } }
.example-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  background: var(--surface2); border: 1px solid var(--border);
  transition: all .15s;
}
.example-link:hover { background: var(--brand-light); border-color: var(--brand-alt); }
.ex-icon { font-size: 16px; flex-shrink: 0; }
.ex-text { flex: 1; min-width: 0; }
.ex-title { display: block; font-size: 13px; font-weight: 700; color: #1F2937; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ex-sub { display: block; font-size: 11px; color: var(--text-muted); margin-top: 1px; }

/* ========== 기준표 ========== */
.table-scroll { margin: 0 20px 16px; border-radius: 10px; border: 1px solid var(--border); overflow: hidden; }
.bracket-table { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; }
.bracket-table thead th { background: var(--brand-light); color: var(--brand-dark); font-weight: 800; padding: 10px 8px; text-align: center; border-bottom: 2px solid var(--brand); font-size: 12px; line-height: 1.4; }
.bracket-table tbody td { padding: 12px 10px; text-align: center; border-bottom: 1px solid var(--border); color: #374151; word-break: keep-all; }
.bracket-table tbody tr:last-child td { border-bottom: none; }
.bracket-table tbody tr:nth-child(even) { background: var(--surface2); }
.bracket-table td.amt { font-weight: 800; color: var(--brand-dark); font-size: 14px; }
.bracket-table .muted { font-size: 11px; color: var(--text-muted); font-weight: 400; display: block; margin-top: 2px; }
.bracket-note { margin: 0 20px 20px; padding: 12px 14px; background: var(--brand-light); border-left: 4px solid var(--brand); border-radius: 8px; font-size: 12.5px; color: var(--brand-dark); line-height: 1.7; }

@media (max-width: 600px) {
  .table-scroll { border: none; background: transparent; }
  .bracket-table, .bracket-table tbody, .bracket-table tr, .bracket-table td { display: block; width: 100%; }
  .bracket-table thead { display: none; }
  .bracket-table tbody tr { background: #fff !important; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
  .bracket-table tbody tr:last-child { margin-bottom: 0; }
  .bracket-table tbody td { text-align: left; border: none; padding: 6px 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13px; }
  .bracket-table tbody td:first-child { border-bottom: 1px dashed var(--border); padding-bottom: 8px; margin-bottom: 4px; }
  .bracket-table tbody td:not(:first-child)::before { content: attr(data-label); font-size: 11.5px; color: var(--text-muted); font-weight: 600; flex-shrink: 0; }
  .bracket-table tbody td.amt { color: var(--brand-dark); font-size: 14px; }
}

/* ========== 시나리오 ========== */
.scenario-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 0 20px 20px; }
.scenario-item { background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.scenario-q { font-size: 13px; color: var(--brand-dark); margin-bottom: 6px; line-height: 1.5; word-break: keep-all; }
.scenario-a { font-size: 12.5px; color: #374151; line-height: 1.65; word-break: keep-all; }
@media (max-width: 720px) { .scenario-grid { grid-template-columns: 1fr; } }

/* ========== 관련 링크 ========== */
.related-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 0 20px 20px; }
.related-link { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: #fff; border: 1px solid var(--border); border-radius: 10px; transition: all .15s; min-width: 0; }
.related-link:hover { background: var(--brand-light); border-color: var(--brand); transform: translateY(-1px); }
.rel-emoji { font-size: 24px; flex-shrink: 0; }
.rel-body { flex: 1; min-width: 0; }
.rel-title { font-size: 13px; font-weight: 700; color: #1F2937; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rel-desc { font-size: 11.5px; color: var(--text-muted); line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 720px) { .related-grid { grid-template-columns: 1fr; } }

/* ========== Sidebar ========== */
.app-sidebar {
  position: sticky; top: 24px; max-height: calc(100vh - 48px);
  overflow-y: auto; scrollbar-width: none; -ms-overflow-style: none;
}
.app-sidebar::-webkit-scrollbar { display: none; }
.sidebar-card { background: var(--surface); border-radius: var(--radius-sm); padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.sidebar-card h3 { font-size: 14px; font-weight: 700; margin-bottom: 12px; padding-left: 8px; border-left: 3px solid var(--brand); color: var(--text); }
.sidebar-list { list-style: none; padding: 0; margin: 0; }
.sidebar-list li { margin-bottom: 6px; }
.sidebar-list a { display: flex; align-items: flex-start; text-decoration: none; color: var(--text); padding: 7px 8px; border-radius: 8px; transition: background .15s; }
.sidebar-list a:hover { background: var(--brand-light); }
.link-icon { margin-right: 8px; font-size: 15px; flex-shrink: 0; margin-top: 1px; }
.link-content { flex: 1; min-width: 0; }
.link-title { display: block; font-size: 13px; font-weight: 600; color: var(--brand-dark); margin-bottom: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-desc { display: block; font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main-footer {
  border-top: 1px solid var(--border); padding: 20px;
  text-align: center; font-size: 12px; color: var(--text-muted);
}

/* ========== Toast ========== */
.share-toast {
  position: fixed; bottom: 80px; left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--brand-dark); color: #fff;
  padding: 12px 22px; border-radius: 99px;
  font-size: 14px; font-weight: 600; white-space: nowrap;
  opacity: 0; transition: opacity .2s, transform .2s;
  z-index: 9999; box-shadow: 0 4px 20px rgba(112, 26, 58, .4); pointer-events: none;
}
.share-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ========== 🏆 최신 당첨번호 배지 ========== */
.latest-card .card-header {
  background: linear-gradient(135deg, var(--brand-dark) 0%, var(--brand) 100%);
}
.latest-card .card-header-title { color: #fff; }
.latest-card .card-header-icon { filter: drop-shadow(0 0 4px rgba(255,255,255,.4)); }
.latest-meta {
  margin-left: auto; font-size: 12px; color: rgba(255,255,255,.9);
  font-weight: 600; letter-spacing: -.2px;
}
.latest-body { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 20px; }
.latest-body .lotto-balls { gap: 8px; }
.latest-bonus {
  display: flex; align-items: center; gap: 6px;
  margin-left: auto; padding-left: 10px; border-left: 1.5px dashed var(--border);
}
.latest-bonus::before {
  content: '+ 보너스'; font-size: 11px; font-weight: 700; color: var(--text-muted);
}
.latest-bonus .lotto-ball { width: 38px; height: 38px; font-size: 14px; }
.latest-error {
  width: 100%; font-size: 13px; color: var(--text-muted); text-align: center; padding: 8px 0;
}
@media (max-width: 520px) {
  .latest-meta { font-size: 11px; }
  .latest-bonus { margin-left: 0; padding-left: 0; border-left: 0; margin-top: 4px; }
}

/* ========== 📈 분석 탭 ========== */
.analysis-tabs {
  display: flex; gap: 6px; padding: 4px; background: var(--surface2);
  border-radius: 12px; border: 1px solid var(--border); margin-bottom: 16px;
}
.analysis-tab {
  flex: 1; padding: 10px 14px; border-radius: 9px;
  font-size: 13px; font-weight: 700; color: var(--text-muted);
  background: transparent; transition: all .15s;
}
.analysis-tab.active {
  background: #fff; color: var(--brand-dark); box-shadow: 0 1px 4px rgba(159, 18, 57, .1);
}
.analysis-tab:hover:not(.active) { color: var(--brand); }
.analysis-loading { text-align: center; color: var(--text-muted); padding: 30px 0; font-size: 14px; }

.analysis-section { margin-bottom: 18px; }
.analysis-section h3 {
  font-size: 14px; font-weight: 800; color: var(--brand-dark);
  margin-bottom: 10px; display: flex; align-items: center; gap: 6px;
}
.analysis-section h3 .subtle {
  font-size: 11px; font-weight: 500; color: var(--text-muted); margin-left: auto;
}

.freq-bars { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
@media (max-width: 520px) { .freq-bars { grid-template-columns: repeat(3, 1fr); } }
.freq-cell {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface2); padding: 6px 8px; border-radius: 8px;
  font-size: 12px; font-weight: 600;
}
.freq-cell .lotto-ball { width: 26px; height: 26px; font-size: 11px; flex-shrink: 0; }
.freq-cell.hot { background: #FEE2E2; color: #9F1239; }
.freq-cell.cold { background: #DBEAFE; color: #1E40AF; }

.stats-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  background: var(--surface2); border-radius: 12px; padding: 14px 10px;
}
.stat-item { text-align: center; }
.stat-label { font-size: 11px; color: var(--text-muted); font-weight: 600; margin-bottom: 2px; }
.stat-value { font-size: 17px; font-weight: 800; color: var(--brand-dark); letter-spacing: -.3px; }

.reco-section { margin-top: 16px; border-top: 1px dashed var(--border); padding-top: 16px; }
.reco-buttons {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px;
}
@media (max-width: 520px) { .reco-buttons { grid-template-columns: 1fr; } }
.reco-btn {
  padding: 12px 8px; border-radius: 10px; border: 1.5px solid var(--border);
  background: #fff; font-size: 13px; font-weight: 700; color: var(--brand-dark);
  transition: all .15s; line-height: 1.35;
}
.reco-btn:hover { border-color: var(--brand); background: var(--brand-light); }
.reco-btn .reco-sub { display: block; font-size: 11px; color: var(--text-muted); font-weight: 500; margin-top: 2px; }
.reco-btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.reco-btn.active .reco-sub { color: rgba(255,255,255,.85); }

.reco-result {
  padding: 14px; background: linear-gradient(135deg, #FFF7FB 0%, #FDF2F8 100%);
  border-radius: 12px; border: 1px dashed var(--brand-light);
}
.reco-result-title { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; font-weight: 600; }
.reco-result .lotto-balls { justify-content: flex-start; }

.round-list { display: flex; flex-wrap: wrap; gap: 6px; }
.round-pill {
  font-size: 11px; padding: 4px 8px; background: var(--surface2);
  border-radius: 99px; color: var(--text-muted); font-weight: 600;
}

/* 오류 상태 */
.analysis-error {
  padding: 20px; background: #FFF7FB; border-radius: 12px;
  text-align: center; color: var(--text-muted); font-size: 13px; line-height: 1.6;
}
