:root {
  --ink: #252323;
  --muted: #77716c;
  --paper: #f5f1e9;
  --card: #fffdf9;
  --coral: #e85d45;
  --coral-dark: #c94330;
  --yellow: #f8c84d;
  --line: #e9e1d6;
  --shadow: 0 24px 70px rgba(77, 54, 34, 0.11);
  --placeholder-ink: #bbb2a7;
  --placeholder-bg: #f4eee5;
  --placeholder-line: #d9cfc2;
  --card-border: rgba(255, 255, 255, 0.8);
  --footer-ink: #989087;
  --toggle-ink: var(--ink);
  --toggle-bg: var(--card);
  --toggle-border: var(--line);
}

:root[data-theme="dark"] {
  --ink: #f3efe8;
  --muted: #b3a99c;
  --paper: #1c1a18;
  --card: #262320;
  --coral: #f0765d;
  --coral-dark: #ff8a70;
  --yellow: #f8c84d;
  --line: #3a352f;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  --placeholder-ink: #7d766c;
  --placeholder-bg: #2c2823;
  --placeholder-line: #453f37;
  --card-border: rgba(255, 255, 255, 0.06);
  --footer-ink: #7d766c;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "DM Sans", sans-serif;
  transition: color 200ms ease, background 200ms ease;
}

body::before,
body::after {
  position: fixed;
  z-index: -1;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  content: "";
  opacity: 0.55;
  filter: blur(1px);
}

body::before {
  top: -110px;
  left: -90px;
  background: var(--yellow);
}

body::after {
  right: -130px;
  bottom: -120px;
  background: #f08c73;
}

.app-shell {
  width: min(100% - 40px, 580px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 42px 0 28px;
}

.hero {
  position: relative;
  padding: 0 6px 34px;
}

.brand-mark {
  display: grid;
  width: 43px;
  height: 43px;
  margin-bottom: 27px;
  color: var(--card);
  background: var(--ink);
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.08em;
  transform: rotate(-8deg);
}

.eyebrow,
.section-label {
  margin: 0;
  color: var(--coral-dark);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin: 12px 0 16px;
  font-family: "Gowun Dodum", serif;
  font-size: clamp(42px, 10vw, 64px);
  font-weight: 400;
  line-height: 1.08;
  letter-spacing: -0.06em;
}

h1 span {
  color: var(--coral);
}

.intro {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.draw-card {
  padding: 30px;
  background: var(--card);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow);
  transition: background 200ms ease, border-color 200ms ease;
}

.card-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

h2 {
  margin: 7px 0 0;
  font-family: "Gowun Dodum", serif;
  font-size: 25px;
  font-weight: 400;
}

.draw-count {
  padding-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.numbers {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin: 34px 0 18px;
}

.number-placeholder,
.number-ball {
  display: grid;
  aspect-ratio: 1;
  width: 100%;
  border-radius: 50%;
  place-items: center;
  font-size: clamp(16px, 4vw, 23px);
  font-weight: 700;
}

.number-placeholder {
  color: var(--placeholder-ink);
  background: var(--placeholder-bg);
  border: 1px dashed var(--placeholder-line);
}

.number-ball {
  color: var(--ink);
  background: var(--yellow);
  animation: pop-in 420ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.number-ball:nth-child(2) { animation-delay: 45ms; }
.number-ball:nth-child(3) { animation-delay: 90ms; }
.number-ball:nth-child(4) { animation-delay: 135ms; }
.number-ball:nth-child(5) { animation-delay: 180ms; }
.number-ball:nth-child(6) { animation-delay: 225ms; }

.result-message {
  min-height: 24px;
  margin-bottom: 26px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.draw-button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  padding: 17px 19px 17px 21px;
  color: white;
  background: var(--coral);
  border: 0;
  border-radius: 0;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  transition: background 180ms ease, transform 180ms ease;
}

.draw-button:hover {
  background: var(--coral-dark);
  transform: translateY(-2px);
}

.draw-button:active {
  transform: translateY(0);
}

.draw-button:focus-visible,
.reset-button:focus-visible {
  outline: 3px solid rgba(37, 35, 35, 0.3);
  outline-offset: 3px;
}

.button-arrow {
  font-size: 22px;
  font-weight: 400;
  line-height: 0.7;
}

.reset-button {
  display: block;
  margin: 18px auto 0;
  padding: 0 0 3px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
}

.reset-button:hover {
  color: var(--ink);
  border-color: var(--ink);
}

.contact-card {
  margin-top: 22px;
  padding: 30px;
  background: var(--card);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow);
  transition: background 200ms ease, border-color 200ms ease;
}

.contact-form {
  display: flex;
  flex-direction: column;
  margin-top: 22px;
}

.field-label {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.field-label:not(:first-child) {
  margin-top: 16px;
}

.field-input {
  padding: 12px 14px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  font: inherit;
  font-size: 14px;
  resize: vertical;
  transition: background 200ms ease, border-color 200ms ease, color 200ms ease;
}

.field-input:focus-visible {
  outline: 3px solid rgba(37, 35, 35, 0.3);
  outline-offset: 2px;
}

.contact-form .draw-button {
  margin-top: 22px;
}

.contact-status {
  min-height: 20px;
  margin: 12px 0 0;
  font-size: 13px;
  text-align: center;
}

.contact-status.is-success {
  color: #2f8f5b;
}

.contact-status.is-error {
  color: var(--coral-dark);
}

.comments-card {
  margin-top: 22px;
  padding: 30px;
  background: var(--card);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow);
  transition: background 200ms ease, border-color 200ms ease;
}

.comment-form {
  display: flex;
  flex-direction: column;
  margin-top: 22px;
}

.comment-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

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

.emoji-picker {
  position: relative;
}

.emoji-trigger,
.image-attach-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  transition: background 200ms ease, border-color 200ms ease, color 200ms ease;
}

.emoji-trigger:hover,
.image-attach-button:hover {
  border-color: var(--coral);
}

.emoji-trigger:focus-visible,
.image-attach-button:has(input:focus-visible) {
  outline: 3px solid rgba(37, 35, 35, 0.3);
  outline-offset: 2px;
}

.emoji-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 4px;
  width: 232px;
  padding: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.emoji-option {
  display: grid;
  padding: 4px;
  background: transparent;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
  font-size: 18px;
  place-items: center;
  transition: background 150ms ease;
}

.emoji-option:hover,
.emoji-option:focus-visible {
  background: var(--placeholder-bg);
  outline: none;
}

.image-preview {
  position: relative;
  width: fit-content;
  margin-top: 14px;
}

.image-preview img {
  display: block;
  max-width: 160px;
  max-height: 160px;
  border: 1px solid var(--line);
  object-fit: cover;
}

.image-remove-button {
  position: absolute;
  top: -8px;
  right: -8px;
  display: grid;
  width: 22px;
  height: 22px;
  color: white;
  background: var(--coral);
  border: 2px solid var(--card);
  border-radius: 50%;
  place-items: center;
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
}

.comment-form .draw-button {
  margin-top: 22px;
}

.comment-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 26px 0 0;
  padding: 0;
  list-style: none;
}

.comment-empty {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.comment-item {
  padding: 16px 18px;
  background: var(--paper);
  border: 1px solid var(--line);
  transition: background 200ms ease, border-color 200ms ease;
}

.comment-item-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.comment-author {
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.comment-time {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.comment-message {
  margin: 8px 0 0;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.comment-image {
  display: block;
  max-width: 220px;
  max-height: 220px;
  margin-top: 10px;
  border: 1px solid var(--line);
  object-fit: cover;
}

.footer-note {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding-top: 25px;
  color: var(--footer-ink);
  font-size: 11px;
}

.theme-toggle {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 10;
  display: grid;
  width: 44px;
  height: 44px;
  color: var(--toggle-ink);
  background: var(--toggle-bg);
  border: 1px solid var(--toggle-border);
  border-radius: 50%;
  place-items: center;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  box-shadow: 0 8px 20px rgba(77, 54, 34, 0.1);
  transition: background 200ms ease, border-color 200ms ease, transform 180ms ease;
}

.theme-toggle:hover {
  transform: translateY(-2px);
}

.theme-toggle:focus-visible {
  outline: 3px solid rgba(37, 35, 35, 0.3);
  outline-offset: 3px;
}

.theme-toggle .icon-dark {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-light {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-dark {
  display: inline;
}

.spark {
  color: var(--coral);
}

@keyframes pop-in {
  from { opacity: 0; transform: scale(0.4) rotate(-15deg); }
  to { opacity: 1; transform: scale(1) rotate(0); }
}

@media (max-width: 480px) {
  .app-shell {
    width: min(100% - 28px, 580px);
    padding-top: 28px;
  }

  .draw-card {
    padding: 24px 18px;
  }

  .numbers {
    gap: 7px;
    margin-top: 28px;
  }
}
