/* Reset */
* {
  box-sizing: border-box;
}

/* Variables */
:root {
  color-scheme: light;
  --page-bg: linear-gradient(135deg, #fff4c2, #f7d794);
  --container-bg: #ffffff;
  --container-border: #f1c40f;
  --heading: #222222;
  --text-muted: #666666;
  --ticket-bg: #fffaf0;
  --ticket-border: #d8b400;
  --row-bg: #ffffff;
  --label-bg: #222222;
  --label-text: #ffffff;
  --notice: #888888;
  --field-bg: #ffffff;
  --field-border: #ddd2a4;
  --field-text: #222222;
  --field-focus: #e1bd21;
  --error: #d63031;
  --success: #218c5a;
  --button-bg: linear-gradient(135deg, #e84118, #fbc531);
  --button-shadow: rgba(232, 65, 24, 0.35);
  --button-shadow-hover: rgba(232, 65, 24, 0.45);
  --theme-button-bg: #ffffff;
  --theme-button-text: #222222;
  --theme-button-border: #e1bd21;
}

/* Layout */
body {
  margin: 0;
  font-family: "Noto Sans KR", Arial, sans-serif;
  background: var(--page-bg);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 24px 20px;
  transition: background 0.25s ease;
}

.container {
  width: 100%;
  max-width: 640px;
  background: var(--container-bg);
  border: 4px solid var(--container-border);
  border-radius: 22px;
  padding: 30px;
  text-align: center;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.18);
  transition: background 0.25s ease, border-color 0.25s ease;
}

.ticket,
.contact-card,
.comments-card {
  background: var(--ticket-bg);
  border: 2px dashed var(--ticket-border);
  border-radius: 16px;
  padding: 20px;
  transition: background 0.25s ease, border-color 0.25s ease;
}

.contact-section,
.comments-section {
  margin-top: 34px;
  text-align: left;
}

.contact-section h2,
.contact-section .subtitle,
.comments-section h2,
.comments-section .subtitle {
  text-align: center;
}

h1,
h2 {
  margin: 0;
  color: var(--heading);
}

h1 {
  font-size: 32px;
}

h2 {
  font-size: 24px;
}

.subtitle {
  margin: 10px 0 25px;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.6;
}

.notice {
  margin-top: 20px;
  color: var(--notice);
  font-size: 13px;
  line-height: 1.5;
}

button {
  border: none;
  background: var(--button-bg);
  color: white;
  padding: 16px 34px;
  border-radius: 40px;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 8px 18px var(--button-shadow);
  transition: transform 0.25s ease, box-shadow 0.25s ease, opacity 0.25s ease;
}

button:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 12px 24px var(--button-shadow-hover);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
  transform: none;
}

/* Header */
.top-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.theme-toggle {
  min-width: 88px;
  height: 44px;
  border: 1px solid var(--theme-button-border);
  background: var(--theme-button-bg);
  color: var(--theme-button-text);
  padding: 0 16px;
  border-radius: 22px;
  font-size: 14px;
  line-height: 1;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.theme-toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
}

/* Lotto Generator */
.ticket {
  margin-bottom: 25px;
}

.ticket-title {
  margin-bottom: 15px;
  color: var(--heading);
  font-size: 18px;
  font-weight: bold;
}

.lotto-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--row-bg);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
  transition: background 0.25s ease;
}

.lotto-row:last-child {
  margin-bottom: 0;
}

.set-label {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--label-bg);
  color: var(--label-text);
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
}

.balls {
  display: flex;
  gap: 7px;
  flex: 1;
  flex-wrap: wrap;
  justify-content: center;
  margin-left: 12px;
}

.ball {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: white;
  font-size: 18px;
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow:
    inset -3px -4px 6px rgba(0, 0, 0, 0.25),
    inset 3px 3px 6px rgba(255, 255, 255, 0.35),
    0 4px 8px rgba(0, 0, 0, 0.2);
}

.yellow { background: #fbc531; }
.blue { background: #0097e6; }
.red { background: #e84118; }
.gray { background: #718093; }
.green { background: #44bd32; }

/* Contact Form */
.contact-card {
  border-style: solid;
}

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

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

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

label {
  color: var(--heading);
  font-size: 14px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--field-border);
  border-radius: 12px;
  background: var(--field-bg);
  color: var(--field-text);
  font: inherit;
  font-size: 15px;
  padding: 13px 14px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.25s ease;
}

textarea {
  min-height: 132px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--field-focus);
  box-shadow: 0 0 0 3px rgba(241, 196, 15, 0.2);
}

.field-error {
  min-height: 17px;
  color: var(--error);
  font-size: 12px;
  line-height: 1.4;
}

.form-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
}

.form-message {
  min-height: 22px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}

.form-message.success {
  color: var(--success);
}

.form-message.error {
  color: var(--error);
}

/* Disqus */
.comments-card {
  min-height: 360px;
  border-style: solid;
}

#disqus_thread {
  min-height: 280px;
  color: var(--field-text);
}

/* Dark Mode */
body.dark {
  color-scheme: dark;
  --page-bg: linear-gradient(135deg, #171923, #2f3542);
  --container-bg: #202434;
  --container-border: #7f8fa6;
  --heading: #f5f6fa;
  --text-muted: #c8d0e0;
  --ticket-bg: #171923;
  --ticket-border: #7f8fa6;
  --row-bg: #2b3042;
  --label-bg: #fbc531;
  --label-text: #171923;
  --notice: #aeb7c7;
  --field-bg: #171923;
  --field-border: #4b556d;
  --field-text: #f5f6fa;
  --field-focus: #fbc531;
  --error: #ff7675;
  --success: #55efc4;
  --button-bg: linear-gradient(135deg, #40739e, #44bd32);
  --button-shadow: rgba(64, 115, 158, 0.35);
  --button-shadow-hover: rgba(68, 189, 50, 0.35);
  --theme-button-bg: #2b3042;
  --theme-button-text: #f5f6fa;
  --theme-button-border: #7f8fa6;
}

/* Responsive */
@media (max-width: 560px) {
  body {
    padding: 16px 12px;
  }

  .container {
    padding: 22px;
  }

  h1 {
    font-size: 28px;
  }

  h2 {
    font-size: 22px;
  }

  .lotto-row {
    flex-direction: column;
    gap: 10px;
  }

  .balls {
    margin-left: 0;
  }

  .ball {
    width: 39px;
    height: 39px;
    font-size: 16px;
  }

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

  button {
    width: 100%;
    padding-inline: 18px;
  }

  .theme-toggle {
    width: auto;
  }
}

/* AI Image Test */
.ai-test-section {
  margin-top: 34px;
  text-align: left;
}

.ai-test-section h2,
.ai-test-section .subtitle,
.ai-result-card h3 {
  text-align: center;
}

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

.ai-test-card,
.ai-result-card {
  background: var(--ticket-bg);
  border: 2px solid var(--ticket-border);
  border-radius: 16px;
  padding: 20px;
  transition: background 0.25s ease, border-color 0.25s ease;
}

.ai-result-card {
  margin-top: 16px;
}

.ai-test-card h3,
.ai-result-card h3 {
  margin: 0;
  color: var(--heading);
  font-size: 18px;
}

.ai-test-copy {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
}

.ai-button-row {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.ai-primary-button,
.ai-secondary-button,
.ai-file-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 40px;
  padding: 0 18px;
  font-size: 15px;
  font-weight: 800;
}

.ai-secondary-button {
  background: var(--theme-button-bg);
  color: var(--theme-button-text);
  border: 1px solid var(--theme-button-border);
  box-shadow: none;
}

.ai-file-label {
  width: 100%;
  margin-top: 16px;
  background: var(--button-bg);
  color: white;
  cursor: pointer;
  box-shadow: 0 8px 18px var(--button-shadow);
}

#aiImageUpload {
  width: 1px;
  height: 1px;
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.ai-preview-frame {
  width: 100%;
  min-height: 240px;
  margin-top: 16px;
  border: 1px dashed var(--ticket-border);
  border-radius: 14px;
  background: var(--row-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.ai-drop-zone {
  cursor: pointer;
  outline: none;
}

.ai-drop-zone.is-drag-over,
.ai-drop-zone:focus-visible {
  border-color: var(--container-border);
  box-shadow: 0 0 0 3px rgba(241, 196, 15, 0.22);
}

.ai-preview-frame canvas,
.ai-preview-frame img {
  width: 100%;
  max-height: 320px;
  display: block;
  object-fit: contain;
}

.ai-empty-preview {
  padding: 16px;
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
}

.ai-status-message {
  margin: 10px 0 0;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 800;
  text-align: center;
}

.ai-top-result {
  display: grid;
  justify-items: center;
  gap: 8px;
  margin-top: 18px;
}

.ai-result-icon {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--label-bg);
  color: var(--label-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-weight: 900;
}

.ai-result-label {
  color: var(--heading);
  font-size: 28px;
}

.ai-result-confidence,
.ai-confidence-text {
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 800;
}

.ai-probability-list {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.ai-probability-item {
  background: var(--row-bg);
  border: 1px solid var(--field-border);
  border-radius: 14px;
  padding: 12px;
}

.ai-probability-item.is-top {
  border-color: var(--container-border);
}

.ai-probability-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--heading);
  font-size: 14px;
  font-weight: 800;
}

.ai-progress-track {
  height: 10px;
  margin-top: 8px;
  border-radius: 999px;
  background: rgba(127, 143, 166, 0.25);
  overflow: hidden;
}

.ai-progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--button-bg);
  transition: width 0.45s ease;
}

.ai-privacy-note {
  margin-top: 16px;
  color: var(--notice);
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
}

@media (max-width: 560px) {
  .ai-test-grid {
    grid-template-columns: 1fr;
  }

  .ai-button-row {
    flex-direction: column;
  }

  .ai-preview-frame {
    min-height: 220px;
  }
}
