:root {
  font-family: "Trebuchet MS", "Noto Sans KR", sans-serif;
  color-scheme: light;
  --ink: #202a3b;
  --muted: #6e7480;
  --line: #e8e0d2;
  --accent: #e4583d;
  --accent-hover: #c94731;
  --bg-page: #f7f4ed;
  --bg-glow: #fffdf7;
  --bg-panel: #fffdf9;
  --bg-ticket: #f8f5ee;
  --line-ticket: #eee6d8;
  --button-ink: #fffdf9;

  color: var(--ink);
  background: var(--bg-page);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #eef1f7;
  --muted: #9aa2b4;
  --line: #363c4c;
  --accent: #ff7452;
  --accent-hover: #ff8c6c;
  --bg-page: #1a1d27;
  --bg-glow: #232838;
  --bg-panel: #20242f;
  --bg-ticket: #262b38;
  --line-ticket: #333947;
  --button-ink: #1a1d27;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  margin: 0;
  padding: 42px 20px 64px;
  background: radial-gradient(circle at 10% 10%, var(--bg-glow) 0, transparent 30%), var(--bg-page);
  transition: background 200ms ease, color 200ms ease;
}

main {
  width: min(100%, 940px);
  margin: 0 auto;
}

.hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 34px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2.3rem, 7vw, 5rem);
  letter-spacing: -0.04em;
  line-height: 0.95;
}

.description {
  max-width: 300px;
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
  text-align: right;
}

.panel {
  padding: 24px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(91, 72, 42, 0.08);
  transition: background 200ms ease, border-color 200ms ease;
}

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

#themeToggle {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: var(--ink);
  font-size: 1.2rem;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

#themeToggle:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

#themeToggle:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

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

#drawButton {
  padding: 12px 18px;
  color: var(--button-ink);
  font: inherit;
  font-weight: 700;
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease;
}

#drawButton:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
}

#drawButton:focus-visible {
  outline: 3px solid #f3b36b;
  outline-offset: 3px;
}

.results {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.ticket {
  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--bg-ticket);
  border: 1px solid var(--line-ticket);
  border-radius: 10px;
  animation: reveal 420ms both;
  transition: background 200ms ease, border-color 200ms ease;
}

.ticket:last-child {
  grid-column: 1 / -1;
}

.ticket-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

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

.ball {
  display: grid;
  place-items: center;
  width: 36px;
  aspect-ratio: 1;
  color: #fff;
  font-size: 0.84rem;
  font-weight: 700;
  border-radius: 50%;
}

.ball.yellow { background: #e4ad32; }
.ball.blue { background: #4b83c5; }
.ball.red { background: #db5b52; }
.ball.gray { background: #89919c; }
.ball.green { background: #4d9b72; }

.plus {
  color: #a49a8b;
  font-size: 1rem;
  font-weight: 700;
}

.draw-info {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: right;
}

.contact-panel {
  margin-top: 24px;
}

.intro-panel {
  padding: 18px 24px;
}

.intro-text {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.intro-text strong {
  color: var(--ink);
}

.panel-note {
  margin: 14px 0 0;
  padding-top: 14px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.6;
  border-top: 1px dashed var(--line);
}

.policy-panel {
  line-height: 1.75;
}

.policy-panel h3 {
  margin: 24px 0 8px;
  font-size: 1rem;
}

.policy-panel h3:first-of-type {
  margin-top: 8px;
}

.policy-panel p,
.policy-panel ul {
  margin: 0 0 10px;
  color: var(--muted);
}

.policy-panel ul {
  padding-left: 20px;
}

.policy-panel a {
  color: var(--accent);
}

.policy-updated {
  margin-top: 24px;
  font-size: 0.82rem;
}

.policy-back {
  margin-top: 8px;
}

.site-footer {
  margin-top: 32px;
  padding-top: 24px;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
  border-top: 1px solid var(--line);
}

.footer-nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 16px;
  margin: 12px 0;
}

.footer-nav a {
  color: var(--muted);
  text-decoration: underline;
}

.footer-nav a:hover,
.footer-nav a:focus-visible {
  color: var(--accent);
}

.footer-copyright {
  margin: 0;
}

.ad-slot {
  margin: 24px 0;
  padding: 16px;
  text-align: center;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  transition: background 200ms ease, border-color 200ms ease;
}

.ad-label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.contact-intro {
  margin: 0 0 20px;
  color: var(--muted);
  line-height: 1.6;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field.full {
  grid-column: 1 / -1;
}

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

.field input,
.field textarea {
  padding: 12px 14px;
  color: var(--ink);
  font: inherit;
  background: var(--bg-ticket);
  border: 1px solid var(--line-ticket);
  border-radius: 8px;
  transition: border-color 160ms ease, background 200ms ease;
}

.field textarea {
  min-height: 110px;
  resize: vertical;
  font-family: inherit;
}

.field input:focus-visible,
.field textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
}

.honeypot {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

#contactSubmit {
  margin-top: 18px;
  padding: 12px 18px;
  color: var(--button-ink);
  font: inherit;
  font-weight: 700;
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, opacity 160ms ease;
}

#contactSubmit:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
}

#contactSubmit:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
}

.contact-status {
  margin: 14px 0 0;
  font-size: 0.88rem;
}

.contact-status.success { color: #4d9b72; }
.contact-status.error { color: #db5b52; }

.animal-panel {
  margin-top: 24px;
}

.animal-intro {
  margin: 0 0 20px;
  color: var(--muted);
  line-height: 1.6;
}

.animal-upload {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

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

.upload-button {
  padding: 12px 18px;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  background: var(--bg-ticket);
  border: 1px solid var(--line-ticket);
  border-radius: 8px;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease;
}

.upload-button:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.upload-button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

#animalAnalyze {
  padding: 12px 18px;
  color: var(--button-ink);
  font: inherit;
  font-weight: 700;
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, opacity 160ms ease;
}

#animalAnalyze:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-2px);
}

#animalAnalyze:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

.animal-preview-wrap {
  margin-top: 18px;
}

.animal-preview-wrap img {
  display: block;
  width: 180px;
  height: 180px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.animal-result {
  margin-top: 20px;
  animation: reveal 420ms both;
}

.animal-verdict {
  margin: 0 0 16px;
  font-size: 1.15rem;
  font-weight: 700;
}

.animal-bars {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.animal-bar-row {
  display: grid;
  grid-template-columns: 110px 1fr 52px;
  align-items: center;
  gap: 12px;
}

.animal-bar-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink);
}

.animal-bar-track {
  height: 14px;
  background: var(--bg-ticket);
  border: 1px solid var(--line-ticket);
  border-radius: 999px;
  overflow: hidden;
}

.animal-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  transition: width 600ms ease;
}

.animal-bar-fill.dog { background: var(--accent); }
.animal-bar-fill.cat { background: #4b83c5; }

.animal-bar-percent {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  text-align: right;
}

@media (max-width: 520px) {
  body {
    padding: 28px 14px 40px;
  }

  .hero,
  .panel-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .description {
    text-align: left;
  }

  .panel {
    padding: 18px;
  }

  .results {
    grid-template-columns: 1fr;
  }

  .ticket:last-child {
    grid-column: auto;
  }

  #drawButton {
    width: 100%;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

  #contactSubmit {
    width: 100%;
  }

  .animal-upload {
    flex-direction: column;
    align-items: stretch;
  }

  .upload-button,
  #animalAnalyze {
    width: 100%;
    text-align: center;
  }

  .animal-bar-row {
    grid-template-columns: 88px 1fr 44px;
    gap: 8px;
  }
}

@keyframes reveal {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
