:root {
  --bg: #f7fbef;
  --surface: #ffffff;
  --surface-strong: #eef8d9;
  --text: #1d2a1f;
  --muted: #6a7764;
  --line: #dce9cb;
  --pickle: #8bc34a;
  --pickle-dark: #547f2d;
  --accent: #ffcf55;
  --danger: #d93a3a;
  --shadow: 0 18px 48px rgba(59, 98, 44, 0.14);
  --pressed-shadow: inset 0 4px 12px rgba(31, 65, 27, 0.18);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

body.dark {
  --bg: #182019;
  --surface: #222d23;
  --surface-strong: #2c3a2a;
  --text: #f1f7e8;
  --muted: #b7c4ad;
  --line: #3d4b38;
  --pickle: #9bd160;
  --pickle-dark: #cde9a6;
  --accent: #ffd76f;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
  --pressed-shadow: inset 0 4px 14px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: Arial, "Noto Sans KR", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 207, 85, 0.22), transparent 34rem),
    linear-gradient(180deg, var(--bg), #eef7e5);
}

body.dark {
  background:
    radial-gradient(circle at top left, rgba(139, 195, 74, 0.14), transparent 34rem),
    linear-gradient(180deg, var(--bg), #121812);
}

button,
a {
  color: inherit;
  font: inherit;
}

a {
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
  object-fit: contain;
}

.site-header {
  position: sticky;
  top: 16px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(1040px, calc(100% - 40px));
  margin: 24px auto 0;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.84);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

body.dark .site-header {
  background: rgba(34, 45, 35, 0.88);
}

.brand,
.header-actions,
.hero-actions,
.bottom-actions,
.section-heading,
.sticky-tools,
.setting-row {
  display: flex;
  align-items: center;
}

.brand {
  min-width: 0;
  gap: 12px;
}

.brand strong {
  display: block;
  font-size: 1.06rem;
  font-weight: 900;
  letter-spacing: 0;
}

.brand small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.82rem;
}

.brand-mascot {
  width: 46px;
  height: 46px;
  object-fit: contain;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 28%, rgba(255, 255, 255, 0.8), transparent 28px),
    linear-gradient(145deg, #effbdc, #cbe985);
  box-shadow: inset 0 0 0 2px rgba(84, 127, 45, 0.18), 0 8px 18px rgba(67, 116, 42, 0.16);
}

.header-actions {
  gap: 10px;
  flex-shrink: 0;
}

.page-shell {
  width: min(1040px, calc(100% - 40px));
  margin: 20px auto 96px;
}

.narrow-shell {
  width: min(860px, 100%);
}

.home-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(220px, 0.65fr);
  gap: 20px;
}

.hero-copy,
.hero-mascot-card,
.latest-draw-card,
.page-title-card,
.tool-card,
.result-header-card,
.disabled-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.84);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

body.dark .hero-copy,
body.dark .hero-mascot-card,
body.dark .latest-draw-card,
body.dark .page-title-card,
body.dark .tool-card,
body.dark .result-header-card,
body.dark .disabled-card {
  background: rgba(34, 45, 35, 0.88);
}

.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 430px;
  padding: 40px;
}

.hero-copy h1 {
  margin: 0;
  max-width: 680px;
  font-size: clamp(3rem, 7vw, 5.6rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.hero-description {
  max-width: 560px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.7;
  word-break: keep-all;
}

.hero-actions {
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 28px;
}

.mode-start-button {
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 148px;
  padding-inline: 20px;
}

.primary-button.mode-start-button {
  min-height: 56px;
}

.mode-start-description {
  display: none;
}

.mode-description-box {
  margin-top: 16px;
  padding: 18px 20px;
  color: var(--muted);
  line-height: 1.6;
  word-break: keep-all;
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-strong);
}

.hero-mascot-card {
  display: grid;
  place-items: center;
  min-height: 430px;
  padding: 28px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 44%, rgba(255, 236, 144, 0.42), transparent 170px),
    rgba(255, 255, 255, 0.84);
}

body.dark .hero-mascot-card {
  background:
    radial-gradient(circle at 50% 44%, rgba(139, 195, 74, 0.2), transparent 170px),
    rgba(34, 45, 35, 0.88);
}

.hero-mascot-card img {
  width: min(300px, 88%);
  max-width: 300px;
  object-fit: contain;
  filter: drop-shadow(0 22px 30px rgba(66, 104, 42, 0.24));
  transform: rotate(4deg);
}

.latest-draw-card {
  grid-column: 1 / -1;
  padding: 22px 24px;
}

.page-title-card + .latest-draw-card {
  margin-top: 20px;
}

.latest-draw-card .kicker {
  margin-bottom: 12px;
}

.latest-draw-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  color: var(--muted);
  min-height: 48px;
  line-height: 1.5;
}

.latest-draw-content.is-error {
  justify-content: flex-start;
}

.latest-draw-meta {
  display: grid;
  gap: 4px;
  min-width: 120px;
}

.latest-draw-meta strong {
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 900;
}

.latest-draw-balls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.latest-draw-balls .lotto-ball {
  width: 40px;
  height: 40px;
}

.bonus-plus {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  color: var(--pickle-dark);
  font-weight: 900;
}

.bonus-ball {
  outline: 2px solid rgba(255, 255, 255, 0.9);
  outline-offset: 2px;
}

.mode-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.mode-card {
  min-height: 148px;
  padding: 22px;
  text-align: left;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  background: var(--surface-strong);
  box-shadow: 0 12px 22px rgba(63, 105, 40, 0.12);
}

.mode-card span {
  display: block;
  font-size: 1.2rem;
  font-weight: 900;
}

.mode-card small {
  display: block;
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.55;
  word-break: keep-all;
}

.page-title-card,
.result-header-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 28px;
}

.page-title-card h1,
.result-header-card h1,
.tool-card h2,
.disabled-card h2 {
  margin: 0;
  line-height: 1.16;
  letter-spacing: 0;
}

.page-title-card h1,
.result-header-card h1 {
  font-size: clamp(2rem, 4vw, 3.2rem);
}

.page-mascot {
  width: 112px;
  height: 112px;
  object-fit: contain;
  border-radius: 24px;
  background: rgba(238, 248, 217, 0.72);
  filter: drop-shadow(0 14px 20px rgba(66, 104, 42, 0.18));
}

body.dark .page-mascot {
  background: rgba(255, 255, 255, 0.06);
}

.tool-card,
.disabled-card {
  margin-top: 20px;
  padding: 24px;
}

.kicker {
  margin: 0 0 8px;
  color: var(--pickle-dark);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.muted-text {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
  word-break: keep-all;
}

.section-heading,
.sticky-tools,
.setting-row,
.result-header-card {
  justify-content: space-between;
}

.sticky-tools {
  position: sticky;
  top: 94px;
  z-index: 10;
  margin: -8px -8px 20px;
  padding: 14px 8px;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, var(--surface), rgba(255, 255, 255, 0.9));
}

body.dark .sticky-tools {
  background: linear-gradient(180deg, var(--surface), rgba(34, 45, 35, 0.9));
}

.icon-button,
.soft-button,
.primary-button,
.chip-button,
.mode-card,
.number-button {
  cursor: pointer;
  border: 0;
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease, border-color 160ms ease;
}

.icon-button:hover,
.soft-button:hover,
.primary-button:hover,
.chip-button:hover,
.mode-card:hover,
.number-button:hover {
  filter: brightness(1.04);
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

button:disabled:hover,
input:disabled:hover {
  filter: none;
}

.icon-button:active,
.soft-button:active,
.primary-button:active,
.chip-button:active,
.mode-card:active,
.number-button:active {
  transform: translateY(2px) scale(0.98);
  box-shadow: var(--pressed-shadow);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--surface-strong);
  box-shadow: 0 8px 18px rgba(67, 116, 42, 0.16);
}

.soft-button,
.primary-button,
.chip-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  border-radius: 999px;
  font-weight: 900;
  white-space: nowrap;
}

.soft-button {
  padding: 12px 17px;
  background: var(--surface-strong);
  box-shadow: 0 8px 16px rgba(76, 111, 54, 0.12);
}

.primary-button {
  padding: 18px 26px;
  color: #17210f;
  background: linear-gradient(135deg, var(--accent), #aee36a);
  box-shadow: 0 14px 26px rgba(84, 127, 45, 0.24);
  font-size: 1.05rem;
}

.primary-button.is-loading {
  gap: 8px;
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.chip-button {
  padding: 13px 18px;
  border: 2px solid transparent;
  background: var(--surface-strong);
  box-shadow: 0 10px 18px rgba(70, 111, 45, 0.12);
}

.mode-card.is-active,
.chip-button.is-active {
  border-color: var(--pickle-dark);
  box-shadow: var(--pressed-shadow);
}

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

.number-button,
.lotto-ball {
  display: inline-grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 50%;
  color: #fff;
  font-weight: 900;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.34);
}

.number-button {
  min-width: 0;
  min-height: 52px;
  border: 3px solid rgba(255, 255, 255, 0.78);
  box-shadow: 0 9px 15px rgba(0, 0, 0, 0.13), inset -4px -5px 0 rgba(0, 0, 0, 0.13);
}

.number-button.is-selected {
  border-color: #ffffff;
  outline: 3px solid var(--pickle-dark);
  transform: translateY(3px) scale(0.96);
  box-shadow: var(--pressed-shadow);
}

.ball-yellow {
  background: linear-gradient(145deg, #ffd85c, #e5a900);
}

.ball-blue {
  background: linear-gradient(145deg, #6eb7ff, #2775cf);
}

.ball-red {
  background: linear-gradient(145deg, #ff7979, #d93a3a);
}

.ball-black {
  background: linear-gradient(145deg, #555c66, #20252b);
}

.ball-green {
  background: linear-gradient(145deg, #86da63, #3b9b45);
}

.count-buttons,
.segmented-control {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}

.generate-inline-button {
  flex: 1 1 170px;
  min-width: 170px;
  padding: 13px 20px;
}

.range-panel {
  display: grid;
  width: 100%;
  min-width: 0;
  gap: 12px;
  margin-top: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-strong);
}

.range-panel label {
  color: var(--muted);
  font-weight: 900;
}

.range-panel input {
  width: 100%;
  accent-color: var(--pickle);
}

.result-list {
  display: grid;
  gap: 16px;
  margin-top: 20px;
}

.result-group {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(84, 127, 45, 0.12);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.34);
}

body.dark .result-group {
  background: rgba(255, 255, 255, 0.04);
}

.result-group-title {
  margin: 0 2px 2px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 900;
  line-height: 1.45;
}

.result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-strong);
}

.result-index {
  flex: 0 0 58px;
  color: var(--muted);
  font-weight: 900;
}

.ball-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  min-width: 0;
}

.lotto-ball {
  width: 42px;
  height: 42px;
  box-shadow: inset -4px -5px 0 rgba(0, 0, 0, 0.13), 0 5px 10px rgba(0, 0, 0, 0.12);
}

.divider {
  height: 1px;
  margin: 0 12px;
  background: linear-gradient(90deg, transparent, var(--line), transparent);
}

.ad-layout {
  display: grid;
  grid-template-columns: minmax(120px, 180px) minmax(0, 860px) minmax(120px, 180px);
  gap: 24px;
  width: min(1300px, calc(100% - 40px));
  margin: 20px auto 96px;
}

.ad-banner,
.side-ad,
.mobile-ad {
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.54);
  font-weight: 900;
}

body.dark .ad-banner,
body.dark .side-ad,
body.dark .mobile-ad {
  background: rgba(255, 255, 255, 0.05);
}

.ad-banner {
  min-height: 74px;
}

.side-ad {
  position: sticky;
  top: 114px;
  height: 420px;
}

.mobile-ad {
  display: none;
}

.empty-message {
  margin: 0;
  padding: 26px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
}

.empty-state-card {
  display: grid;
  gap: 12px;
  padding: 28px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-strong);
}

.empty-state-card h2 {
  margin: 0;
  color: var(--text);
  font-size: 1.45rem;
}

.empty-state-card p {
  margin: 0;
  line-height: 1.6;
}

.empty-state-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
}

.bottom-actions {
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
}

.bottom-actions .primary-button,
.bottom-actions .soft-button {
  min-width: 180px;
}

.setting-row {
  gap: 20px;
}

.setting-row .segmented-control {
  margin-top: 0;
}

.disabled-card {
  opacity: 0.78;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 30;
  padding: 12px 16px;
  color: #17210f;
  background: #ffdf75;
  border-radius: 999px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 1120px) {
  .ad-layout {
    grid-template-columns: minmax(0, 1fr);
    width: min(860px, calc(100% - 40px));
  }

  .side-ad {
    display: none;
  }

  .mobile-ad {
    position: sticky;
    bottom: 12px;
    z-index: 15;
    display: grid;
    min-height: 58px;
    margin-top: 20px;
    border-radius: 999px;
    box-shadow: var(--shadow);
  }
}

@media (max-width: 768px) {
  .site-header,
  .page-shell,
  .ad-layout {
    width: min(100% - 24px, 680px);
  }

  .site-header {
    top: 10px;
    margin-top: 12px;
    border-radius: 22px;
  }

  .page-shell,
  .ad-layout {
    margin-bottom: 36px;
  }

  .brand small {
    display: none;
  }

  .brand-mascot {
    width: 40px;
    height: 40px;
  }

  .icon-button {
    width: 52px;
    height: 52px;
    flex: 0 0 52px;
  }

  .home-shell,
  .mode-grid {
    grid-template-columns: 1fr;
  }

  .home-shell {
    gap: 14px;
  }

  .hero-copy,
  .hero-mascot-card,
  .latest-draw-card {
    min-height: auto;
    padding: 22px;
  }

  .latest-draw-content {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .latest-draw-balls {
    justify-content: flex-start;
  }

  .tool-card,
  .disabled-card {
    padding: 20px;
  }

  .mode-start-button,
  .generate-inline-button {
    min-width: 0;
  }

  .hero-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .mode-start-button {
    align-items: flex-start;
    width: 100%;
    padding: 14px 18px;
    text-align: left;
  }

  .primary-button.mode-start-button {
    min-height: 72px;
  }

  .mode-start-description {
    display: block;
    color: rgba(23, 33, 15, 0.76);
    font-size: 0.86rem;
    line-height: 1.45;
    white-space: normal;
    word-break: keep-all;
  }

  .mode-description-box {
    display: none;
  }

  .hero-mascot-card img {
    width: min(180px, 62vw);
    max-width: 180px;
  }

  .page-title-card,
  .result-header-card,
  .sticky-tools,
  .setting-row,
  .result-row,
  .bottom-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .page-mascot {
    width: 86px;
    height: 86px;
  }

  .sticky-tools {
    top: 82px;
  }

  .number-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 9px;
  }

  .number-button {
    min-height: 54px;
    font-size: 1rem;
  }

  .count-buttons {
    align-items: stretch;
  }

  .chip-button {
    flex: 1 1 calc(50% - 10px);
    min-height: 54px;
  }

  .generate-inline-button {
    flex-basis: 100%;
    min-height: 56px;
  }

  .range-panel {
    padding: 16px;
    overflow: hidden;
  }

  .range-panel input {
    min-width: 0;
  }

  .soft-button,
  .primary-button,
  .bottom-actions .primary-button,
  .bottom-actions .soft-button {
    width: 100%;
  }

  .ball-list {
    justify-content: flex-start;
    gap: 7px;
  }

  .lotto-ball {
    width: 40px;
    height: 40px;
  }

  .result-row {
    gap: 12px;
    padding: 13px;
  }

  .result-index {
    flex-basis: auto;
  }

  .mobile-ad {
    position: static;
    min-height: 54px;
    margin-top: 18px;
    border-radius: var(--radius-md);
  }

  .mobile-ad .ad-banner {
    width: 100%;
    min-height: 54px;
    border: 0;
    background: transparent;
    border-radius: inherit;
  }
}

@media (max-width: 380px) {
  .number-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 7px;
  }

  .number-button {
    min-height: 52px;
    border-width: 2px;
  }

  .lotto-ball {
    width: 38px;
    height: 38px;
  }
}
