:root {
  --bg: #0f1226;
  --bg-glow: #2a2f6b;
  --card: #1a1e3a;
  --card2: #232853;
  --accent: #ffd23f;          /* 버튼/알약 배경·테두리 (양쪽 테마 공통) */
  --accent2: #ff6b6b;
  --accent-ink: #ffd23f;      /* 배경 위 강조 '텍스트' 색 (가독성용) */
  --text: #e8eaf6;
  --muted: #9aa0c8;
  --border: rgba(255, 255, 255, .10);
  --shadow: rgba(0, 0, 0, .25);
  --ok: #7ee787;
  --warn: #ffb3b3;
  --radius: 16px;
}

:root[data-theme="light"] {
  --bg: #eef1f8;
  --bg-glow: #dbe3f6;
  --card: #ffffff;
  --card2: #eef1f8;
  --accent: #ffd23f;
  --accent2: #ff6b6b;
  --accent-ink: #9a7400;      /* 흰 배경에서 읽히는 진한 골드 */
  --text: #1b2140;
  --muted: #5c6488;
  --border: rgba(20, 25, 60, .12);
  --shadow: rgba(30, 45, 100, .12);
  --ok: #1a9d4b;
  --warn: #c62f2f;
}

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

/* body가 max-width로 가운데 정렬되므로, 넓은 화면의 양옆 여백도 테마색으로 채움 */
html { background-color: var(--bg); }

body {
  font-family: "Segoe UI", "Malgun Gothic", system-ui, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, var(--bg-glow) 0%, var(--bg) 55%);
  background-color: var(--bg);
  min-height: 100vh;
  color: var(--text);
  line-height: 1.55;
  padding: 24px 16px 64px;
  max-width: 1000px;
  margin: 0 auto;
  transition: background-color .25s ease, color .25s ease;
}

.site-header { text-align: center; margin-bottom: 16px; }
.site-header h1 { font-size: 1.9rem; letter-spacing: -.5px; }
.site-header h1 .brand {
  font-size: .95rem; font-weight: 700; vertical-align: middle;
  color: #241a00; background: var(--accent);
  padding: 2px 10px; border-radius: 999px; margin-left: 6px;
}
.site-header .sub { color: var(--muted); margin-top: 6px; }

.disclaimer {
  background: rgba(255, 107, 107, .12);
  border: 1px solid rgba(255, 107, 107, .4);
  color: #ffd9d9;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: .86rem;
  margin-bottom: 24px;
}
:root[data-theme="light"] .disclaimer { color: #9a2222; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 20px;
  box-shadow: 0 8px 30px var(--shadow);
  transition: background-color .25s ease, border-color .25s ease;
}
.card h2 { font-size: 1.2rem; margin-bottom: 14px; }
.card h3 { font-size: .95rem; color: var(--muted); margin: 14px 0 8px; font-weight: 600; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 720px) { .grid { grid-template-columns: 1fr; } }

.controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-bottom: 8px; }
.controls label { display: flex; flex-direction: column; font-size: .8rem; color: var(--muted); gap: 4px; }
select, input, button {
  font: inherit;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card2);
  color: var(--text);
}
button {
  background: linear-gradient(135deg, var(--accent), #ffb700);
  color: #241a00;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: transform .08s ease, filter .15s ease;
}
button:hover { filter: brightness(1.05); }
button:active { transform: scale(.97); }

/* 로또 공 */
.ball {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 42px; height: 42px;
  border-radius: 50%;
  font-weight: 700;
  color: #fff;
  box-shadow: inset 0 -3px 6px rgba(0,0,0,.25), 0 2px 4px rgba(0,0,0,.3);
  flex: 0 0 auto;
}
.ball.sm { width: 34px; height: 34px; font-size: .85rem; }
/* 번호대별 색상 (동행복권 방식) */
.c1 { background: #fbc400; }   /* 1-10 */
.c2 { background: #69c8f2; }   /* 11-20 */
.c3 { background: #ff7272; }   /* 21-30 */
.c4 { background: #aaa; }       /* 31-40 */
.c5 { background: #b0d840; }    /* 41-45 */

.ball-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ball .cnt { font-size: .6rem; opacity: .85; }

.recommend { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.set-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--card2);
  padding: 10px 14px; border-radius: 12px;
}
.set-row .tag { color: var(--muted); font-size: .8rem; width: 42px; }
.set-row .meta { margin-left: auto; color: var(--muted); font-size: .75rem; }

.note { color: var(--muted); font-size: .75rem; margin-top: 12px; }

.recent-list { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; }
.recent-item { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.recent-item .rd { color: var(--accent-ink); font-weight: 700; width: 64px; font-size: .85rem; }
.plus { color: var(--muted); margin: 0 2px; }

/* 막대 그래프 */
.bar-chart {
  display: flex; align-items: flex-end; gap: 3px; height: 200px;
  padding: 20px 0 26px;
  /* 좁은 화면(모바일)에서 45개 막대가 넘칠 때 카드 안에서 가로 스크롤 */
  overflow-x: auto; overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}
.bar-chart.small { height: 150px; gap: 8px; }
.bar {
  flex: 1 1 0; min-width: 12px;
  background: linear-gradient(180deg, var(--accent), #ff8a00);
  border-radius: 4px 4px 0 0;
  position: relative;
  display: flex; align-items: flex-start; justify-content: center;
  transition: filter .15s;
}
.bar:hover { filter: brightness(1.2); }
.bar .lbl { position: absolute; bottom: -20px; font-size: .6rem; color: var(--muted); white-space: nowrap; }
.bar .val { position: absolute; top: -16px; font-size: .6rem; color: var(--text); }
.bar-chart.small .bar { background: linear-gradient(180deg, #69c8f2, #3b82f6); }

#lookupResult { margin-top: 14px; }

/* 업데이트 바 */
.update-bar { display: flex; align-items: center; gap: 12px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }

/* 다크/라이트 테마 토글 (원형 버튼) */
.theme-toggle {
  flex: 0 0 auto;
  width: 40px; height: 40px; padding: 0;
  border-radius: 50%;
  font-size: 1.1rem; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--card2); color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px var(--shadow);
}
.theme-toggle:hover { filter: brightness(1.1); }
button.ghost {
  background: transparent;
  border: 1px solid var(--accent-ink);
  color: var(--accent-ink);
  font-weight: 600;
  padding: 7px 14px;
}
button.ghost:hover { background: rgba(255, 210, 63, .12); }
.update-status { font-size: .82rem; color: var(--muted); }
.update-status.ok { color: var(--ok); }
.update-status.warn { color: var(--warn); }

/* 작은 버튼 (저장/삭제) */
button.mini {
  padding: 5px 10px; font-size: .78rem; border-radius: 8px;
  background: var(--card); color: var(--accent-ink);
  border: 1px solid rgba(255, 210, 63, .5);
}
button.mini:hover { background: rgba(255, 210, 63, .12); }
button.mini.danger { color: var(--warn); border-color: rgba(255, 107, 107, .5); }
button.mini.danger:hover { background: rgba(255, 107, 107, .12); }

/* QR 스캔 */
#qrVideo {
  display: none;
  width: 100%;
  max-width: 360px;
  border-radius: 12px;
  margin: 12px 0;
  background: #000;
  border: 2px solid var(--accent);
}
.filebtn {
  display: inline-flex; align-items: center;
  padding: 9px 14px; border-radius: 10px; cursor: pointer;
  background: var(--card2); color: var(--text);
  border: 1px solid var(--border);
  font-weight: 600;
}
.filebtn:hover { filter: brightness(1.1); }

/* 당첨 확인 결과 */
.check-box {
  margin-top: 14px; padding: 16px; border-radius: 12px;
  background: var(--card2);
  border-left: 5px solid var(--muted);
}
.check-box.rank-1 { border-left-color: #ffd23f; background: rgba(255, 210, 63, .12); }
.check-box.rank-2, .check-box.rank-3 { border-left-color: #7ee787; background: rgba(126, 231, 135, .10); }
.check-box.rank-4, .check-box.rank-5 { border-left-color: #69c8f2; background: rgba(105, 200, 242, .10); }
.check-box.rank-0 { border-left-color: #ff6b6b; }
.check-title { margin-bottom: 10px; font-size: 1.05rem; }
.check-title .rank { font-weight: 700; }

footer { text-align: center; color: var(--muted); font-size: .78rem; margin-top: 30px; }

/* ── 태블릿/모바일 반응형 ── */
@media (max-width: 600px) {
  body { padding: 16px 12px 48px; }
  .site-header h1 { font-size: 1.4rem; line-height: 1.3; }
  .site-header h1 .brand { display: inline-block; margin-top: 6px; }
  .disclaimer { font-size: .82rem; padding: 11px 13px; }
  .card { padding: 16px 15px; }
  .card h2 { font-size: 1.1rem; }

  /* 폼 컨트롤을 세로로 쌓아 터치하기 쉽게 + 인라인 min-width 가로넘침 방지 */
  .controls { flex-direction: column; align-items: stretch; gap: 10px; }
  .controls > label,
  .controls > select,
  .controls > input,
  .controls > button,
  .controls > .filebtn { width: 100%; }
  .controls label select,
  .controls label input { width: 100%; }
  #qrUrl, #checkNums, #checkRound, #myNumInput, #roundInput,
  #companionNum, #qrButtons button {
    min-width: 0 !important; width: 100% !important;
  }
  .filebtn { justify-content: center; }

  .ball { width: 38px; height: 38px; }
  .ball.sm { width: 32px; height: 32px; }
}
