* {
  box-sizing: border-box;
}

/* ----- 테마 색상 (라이트 모드 기본값) ----- */
:root {
  --bg-gradient: linear-gradient(135deg, #1e3c72, #2a5298);
  --card: #ffffff;
  --text: #222222;
  --text-sub: #666666;
  --text-muted: #999999;
  --row: #f6f7fb;
  --border: #eeeeee;
  --input-bg: #ffffff;
  --input-border: #cccccc;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  color-scheme: light;
}

/* 다크 모드일 때 바뀌는 색상 */
:root[data-theme="dark"] {
  --bg-gradient: linear-gradient(135deg, #0b0f1a, #1a1f33);
  --card: #1e2233;
  --text: #eceef5;
  --text-sub: #a8adc0;
  --text-muted: #7c8198;
  --row: #272c40;
  --border: #33384d;
  --input-bg: #272c40;
  --input-border: #444a63;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background: var(--bg-gradient);
  color: var(--text);
  display: flex;
  justify-content: center;
  padding: 32px 16px;
}

.container {
  width: 100%;
  max-width: 560px;
  background: var(--card);
  border-radius: 20px;
  padding: 28px 24px;
  box-shadow: var(--shadow);
  transition: background 0.3s;
}

header {
  text-align: center;
  position: relative;
  padding: 0 40px; /* 테마 버튼과 제목이 겹치지 않게 */
}

/* 테마 전환 버튼 (오른쪽 위) */
.theme-toggle {
  position: absolute;
  top: -12px;
  right: -8px;
  background: var(--row);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  padding: 0;
  font-size: 1.2rem;
  line-height: 1;
}

.theme-toggle:hover {
  transform: rotate(20deg);
}

h1 {
  margin: 0;
  font-size: 1.8rem;
}

.subtitle {
  margin: 8px 0 0;
  color: var(--text-sub);
}

/* 조작 영역 */
.controls {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin: 24px 0;
}

select,
button {
  font: inherit;
  border-radius: 10px;
  padding: 10px 16px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
}

button {
  cursor: pointer;
}

button.primary {
  background: #ff6b35;
  color: #fff;
  border: none;
  font-weight: bold;
  transition: transform 0.1s, background 0.2s;
}

button.primary:hover {
  background: #e85a24;
}

button.primary:active {
  transform: scale(0.96);
}

button.primary:disabled {
  background: #aaa;
  cursor: wait;
}

button.ghost {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 4px 8px;
  font-size: 0.85rem;
}

/* 결과 */
.results {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 80px;
}

.empty {
  text-align: center;
  color: var(--text-muted);
}

.row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  background: var(--row);
  border-radius: 12px;
  flex-wrap: wrap;
}

.row-label {
  width: 22px;
  font-weight: bold;
  color: var(--text-sub);
}

.plus {
  color: var(--text-muted);
  font-weight: bold;
  margin: 0 2px;
}

/* 로또 공 */
.ball {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  box-shadow: inset -3px -3px 6px rgba(0, 0, 0, 0.2),
    inset 3px 3px 6px rgba(255, 255, 255, 0.35);
  animation: pop 0.35s ease-out both;
}

.ball.small {
  width: 28px;
  height: 28px;
  font-size: 0.75rem;
  animation: none;
}

/* 실제 동행복권 색상 규칙 */
.c1 { background: #fbc400; } /* 1~10 */
.c2 { background: #69c8f2; } /* 11~20 */
.c3 { background: #ff7272; } /* 21~30 */
.c4 { background: #aaaaaa; } /* 31~40 */
.c5 { background: #b0d840; } /* 41~45 */

@keyframes pop {
  0%   { transform: scale(0) rotate(-180deg); opacity: 0; }
  80%  { transform: scale(1.15) rotate(10deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}

/* 기록 */
.history-section {
  margin-top: 32px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

h2 {
  margin: 0;
  font-size: 1.1rem;
}

.history {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
}

.history li {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.history time {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-right: 6px;
  min-width: 60px;
}

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

@media (max-width: 420px) {
  .ball {
    width: 34px;
    height: 34px;
    font-size: 0.9rem;
  }
}
