/* 모바일 우선(mobile-first) 스타일.
   기본 규칙은 좁은 화면 기준으로 쓰고, 화면이 넓어지면 미디어 쿼리로 확장한다.

   CSP가 외부 출처를 전부 막고 있어서 웹폰트·아이콘 라이브러리를 쓸 수 없다.
   장식은 전부 시스템 폰트와 CSS 그라데이션·그림자로만 만든다. */

:root {
  color-scheme: light dark;
  --bg: #fbfaff;
  --surface: #ffffff;
  --fg: #22242e;
  --muted: #6b7182;
  --border: #e8e6f4;
  --accent: #7c5cf0;
  --accent-2: #ec4899;
  --accent-fg: #ffffff;
  --accent-soft: rgba(124, 92, 240, 0.08);
  /* 제목과 배경에 쓰는 화사한 3색: 앰버 → 핑크 → 바이올렛 */
  --pop-1: #f9a825;
  --pop-2: #f2589b;
  --pop-3: #8b5cf6;
  /* 제목 앞부분 '로또 6/45' 연두색.
     흰 배경에서도 읽히도록 큰 글자 기준(3:1)을 넘는 선까지만 밝게 잡았다. */
  --brand-green: #5f9e0d;
  /* 실험 세트 로고 색 */
  --lab-ink: #1f2430;
  --lab-glass: #dce5f0;
  --lab-bulb: #8e3220;
  --lab-liquid: #d2661f;
  --lab-bubble: #f0913f;
  --wash-1: rgba(249, 168, 37, 0.15);
  --wash-2: rgba(242, 88, 155, 0.15);
  --wash-3: rgba(139, 92, 246, 0.14);
  --warn-bg: #fff8e6;
  --warn-border: #f2dda3;
  --warn-fg: #6b4e00;
  --shadow-sm: 0 1px 2px rgba(20, 24, 40, 0.06);
  --shadow-md: 0 4px 16px rgba(20, 24, 40, 0.08);
  --radius: 12px;
  --radius-lg: 16px;
  --gap: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101219;
    --surface: #191c25;
    --fg: #eceef5;
    --muted: #98a0b3;
    --border: #2a2f3d;
    --accent: #a78bfa;
    --accent-2: #f472b6;
    --accent-fg: #14161f;
    --accent-soft: rgba(167, 139, 250, 0.14);
    --pop-1: #fbbf24;
    --pop-2: #f472b6;
    --pop-3: #a78bfa;
    /* 어두운 배경에서는 훨씬 밝은 연두가 잘 읽힌다. */
    --brand-green: #a3e635;
    /* 로고 외곽선도 어두운 배경에서는 밝은 색이어야 보인다. */
    --lab-ink: #e6e9f2;
    --lab-glass: #3b4557;
    --lab-bulb: #c4553a;
    --lab-liquid: #e07733;
    --lab-bubble: #f7ab5c;
    --wash-1: rgba(251, 191, 36, 0.08);
    --wash-2: rgba(244, 114, 182, 0.09);
    --wash-3: rgba(167, 139, 250, 0.11);
    --warn-bg: #2a2415;
    --warn-border: #4a3f22;
    --warn-fg: #e8d9a8;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
  }
}

* {
  box-sizing: border-box;
}

/* text-size-adjust 는 일부러 쓰지 않는다.
   이 속성은 엔진마다 이름이 갈려서(-webkit- / -moz- / 접두사 없음) 어떤 조합을
   써도 "나머지 브라우저가 지원하지 않는다"는 경고가 남는다. 원래 용도인
   '모바일에서 글자가 제멋대로 커지는 현상' 방지는 아래 뷰포트 설정으로 이미
   해결된다 (index.html 의 meta viewport: width=device-width, initial-scale=1).
   글자 자동 확대는 뷰포트 설정이 없는 옛날식 페이지에만 일어나기 때문이다. */

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  /* 화면 위쪽에 세 가지 색을 옅게 겹쳐 화사한 느낌을 준다. */
  background-image:
    radial-gradient(ellipse 65% 38% at 10% 0%, var(--wash-1), transparent 66%),
    radial-gradient(ellipse 70% 42% at 52% 0%, var(--wash-2), transparent 68%),
    radial-gradient(ellipse 75% 46% at 95% 0%, var(--wash-3), transparent 70%);
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic",
    "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  overflow-wrap: break-word;
}

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px max(16px, env(safe-area-inset-left)) calc(32px + env(safe-area-inset-bottom));
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.is-hidden {
  display: none !important;
}

/* ---------- 헤더 ---------- */

.site-header {
  margin-bottom: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ---------- 실험 세트 로고 (비커 + 스포이드) ----------
   CSP가 인라인 <style> 을 막고 있어서 SVG는 HTML에 인라인으로 넣고
   색과 움직임은 전부 여기서 준다. */

.brand-logo {
  display: block;
  flex: 0 0 auto;
  width: 54px;
  height: 54px;
}

.brand-logo svg {
  display: block;
  width: 100%;
  height: 100%;
}

.lab-stroke {
  fill: none;
  stroke: var(--lab-ink);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lab-glass {
  fill: var(--lab-glass);
  stroke: var(--lab-ink);
  stroke-width: 2;
  stroke-linejoin: round;
}

.lab-bulb {
  fill: var(--lab-bulb);
  stroke: var(--lab-ink);
  stroke-width: 2;
}

.lab-liquid {
  fill: var(--lab-liquid);
}

.lab-mark {
  fill: none;
  stroke: var(--lab-ink);
  stroke-width: 2;
  stroke-linecap: round;
}

.lab-bubble {
  fill: var(--lab-bubble);
  /* fill-box 로 잡아야 scale 이 각 기포의 중심을 기준으로 커진다. */
  transform-box: fill-box;
  transform-origin: center;
  animation: lab-bubble-rise 2.8s ease-in infinite;
}

.lab-bubble-1 { animation-duration: 2.6s; animation-delay: 0s; }
.lab-bubble-2 { animation-duration: 3.2s; animation-delay: 0.7s; }
.lab-bubble-3 { animation-duration: 2.9s; animation-delay: 1.3s; }
.lab-bubble-4 { animation-duration: 3.5s; animation-delay: 1.9s; }

/* 액체 속에서 생긴 기포가 위로 올라가며 커지다 수면 위에서 사라진다. */
@keyframes lab-bubble-rise {
  0% {
    transform: translateY(2px) scale(0.4);
    opacity: 0;
  }
  20% {
    opacity: 1;
  }
  80% {
    opacity: 0.9;
  }
  100% {
    transform: translateY(-26px) scale(1);
    opacity: 0;
  }
}

.lab-drop {
  fill: var(--lab-liquid);
  transform-box: fill-box;
  transform-origin: center;
  animation: lab-drop-fall 3.2s ease-in infinite;
}

/* 스포이드 끝에 물방울이 맺혔다가 비커로 떨어진다. */
@keyframes lab-drop-fall {
  0%, 8% {
    transform: translateY(0) scale(0.5);
    opacity: 0;
  }
  22% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
  62% {
    transform: translateY(13px) scale(1);
    opacity: 1;
  }
  72%, 100% {
    transform: translateY(14px) scale(0.6);
    opacity: 0;
  }
}

.site-header h1 {
  margin: 0;
  font-size: 1.42rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0;
}

.brand-title {
  color: var(--brand-green);
  font-weight: 900;
}

/* 한글 시스템 폰트(맑은 고딕 등)는 Bold(700)까지밖에 없어서, font-weight 를
   900 으로 줘도 '로또'는 700 으로만 그려진다. 반면 숫자 '6/45'는 Black(900)이
   있는 라틴 폰트로 그려져 훨씬 굵게 나온다. 그 차이를 메우려고 한글 쪽에만
   외곽선을 덧대 두께를 맞춘다. paint-order 로 채움을 외곽선 위에 얹어야
   글자 속 빈 공간이 뭉개지지 않는다. */
.brand-lotto {
  -webkit-text-stroke: 0.9px currentColor;
  paint-order: stroke fill;
}

.brand-accent {
  color: var(--accent-2);
  font-weight: 700;
}

/* 그라데이션 글자. 지원하지 않는 브라우저에서는 위의 단색이 그대로 보인다. */
@supports (background-clip: text) or (-webkit-background-clip: text) {
  .brand-accent {
    background-image: linear-gradient(100deg, var(--pop-1), var(--pop-2) 48%, var(--pop-3));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }
}

.meta {
  display: inline-block;
  margin: 16px 0 0;
  padding: 7px 15px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  color: var(--muted);
  font-size: 0.76rem;
}

/* ---------- 공통 섹션 ---------- */

.predictions {
  margin-bottom: 24px;
  padding: 18px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.predictions h2 {
  margin: 0 0 10px;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.disclaimer {
  margin: 0 0 14px;
  padding: 11px 13px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: var(--radius);
  color: var(--warn-fg);
  font-size: 0.8rem;
  line-height: 1.55;
}

.predictions-meta {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.8rem;
  min-height: 1.2em;
}

/* ---------- 예측 카드 ---------- */

.prediction-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap);
}

.prediction-card {
  position: relative;
  padding: 15px 14px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

/* 카드 위쪽의 얇은 강조선 */
.prediction-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.prediction-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.prediction-card h3 {
  display: inline-block;
  margin: 0 0 11px;
  padding: 3px 9px;
  background: var(--accent-soft);
  border-radius: 999px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 700;
}

.prediction-card .balls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 11px;
}

.prediction-card .reason {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.6;
}

/* ---------- 버튼 ---------- */

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px; /* 터치 타깃 최소 크기 */
  padding: 10px 17px;
  border: 1px solid transparent;
  border-radius: 10px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

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

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.55;
  cursor: progress;
  transform: none;
}

.btn-primary {
  background-image: linear-gradient(120deg, var(--accent), var(--accent-2));
  box-shadow: var(--shadow-sm);
  color: var(--accent-fg);
}

.btn-primary:hover {
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--fg);
}

.btn-quiet {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}

.btn-quiet:hover {
  color: var(--fg);
}

/* ---------- 검색 컨트롤 ---------- */

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.field label {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 600;
}

.field input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  font-size: 0.9rem;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

.field-actions {
  grid-column: 1 / -1;
  flex-direction: row;
  gap: 8px;
}

.field-actions .btn {
  flex: 1;
}

/* ---------- 결과 목록 ---------- */

.result-count {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.78rem;
}

.table-scroll {
  overflow-x: auto;
  border-radius: var(--radius-lg);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 12px;
  text-align: left;
  font-size: 0.87rem;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.empty-row td {
  padding: 28px 12px;
  color: var(--muted);
  text-align: center;
}

.more-row {
  margin-top: 18px;
  text-align: center;
}

.more-row .btn {
  width: 100%;
}

/* ---------- 당첨 번호 공 ---------- */

.balls {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
}

/* 색상은 .b1~.b5 가 background-color 로 지정하고,
   여기서는 그 위에 공통으로 하이라이트와 그림자만 얹는다. */
.ball {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 31px;
  height: 31px;
  border-radius: 50%;
  background-image: radial-gradient(
    circle at 32% 26%,
    rgba(255, 255, 255, 0.45),
    rgba(255, 255, 255, 0) 58%
  );
  box-shadow: 0 1px 3px rgba(20, 24, 40, 0.22), inset 0 -2px 4px rgba(0, 0, 0, 0.16);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.ball.b1 { background-color: #cf9500; color: #241a00; }
.ball.b2 { background-color: #1a86b8; }
.ball.b3 { background-color: #d13b3b; }
.ball.b4 { background-color: #64697a; }
.ball.b5 { background-color: #5a8511; }

.plus {
  margin: 0 3px;
  color: var(--muted);
  font-weight: 700;
}

/* ---------- 푸터 ---------- */

.site-footer {
  margin-top: 34px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.6;
}

.site-footer p {
  margin: 0;
}

/* ---------- 좁은 화면: 표를 카드로 전환 ---------- */

@media (max-width: 639px) {
  #lottoTable thead {
    display: none;
  }

  #lottoTable,
  #lottoTable tbody,
  #lottoTable tr,
  #lottoTable td {
    display: block;
    width: 100%;
  }

  #lottoTable tr {
    margin-bottom: 10px;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
  }

  #lottoTable td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 5px 0;
    border-bottom: none;
  }

  #lottoTable td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 600;
  }

  #lottoTable td.cell-numbers {
    flex-direction: column;
    align-items: flex-start;
    gap: 7px;
    padding-top: 9px;
  }

  #lottoTable tr.empty-row {
    background: transparent;
    box-shadow: none;
  }

  #lottoTable tr.empty-row td {
    justify-content: center;
  }

  #lottoTable tr.empty-row td::before {
    content: none;
  }
}

/* ---------- 태블릿 이상 ---------- */

@media (min-width: 640px) {
  .page {
    padding: 32px max(20px, env(safe-area-inset-left)) 44px;
  }

  .brand-logo {
    width: 66px;
    height: 66px;
  }

  .site-header h1 {
    font-size: 1.9rem;
  }

  .predictions {
    padding: 22px 20px;
  }

  .prediction-cards {
    grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr));
  }

  .controls {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
  }

  .field {
    width: 160px;
  }

  .field-actions {
    width: auto;
    flex: 0 0 auto;
  }

  .field-actions .btn {
    flex: 0 0 auto;
  }

  /* 표는 넓은 화면에서만 카드 컨테이너로 감싼다. */
  .table-scroll {
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
  }

  th {
    background: var(--bg);
  }

  td {
    white-space: nowrap;
  }

  td.cell-numbers {
    white-space: normal;
  }

  tbody tr {
    transition: background-color 0.12s ease;
  }

  tbody tr:hover {
    background: var(--accent-soft);
  }

  tbody tr:last-child td {
    border-bottom: none;
  }

  .more-row .btn {
    width: auto;
    min-width: 220px;
  }
}

@media (min-width: 900px) {
  .site-header h1 {
    font-size: 1.95rem;
  }
}

/* ---------- 접근성: 모션 최소화 ---------- */

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
