/* ===== Reset & Variables ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #FE304A;
  --primary-dark: #e52b42;
  --primary-light: #ff6b7a;
  --secondary: #ff8fa3;
  --dark: #1a1a2e;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-600: #475569;
  --gray-800: #1e293b;
  --receipt-bg: #f5f0eb;
  --receipt-paper: #fffdf7;
  --receipt-text: #2c2c2c;
  --receipt-light: #8a8a8a;
  --gradient-1: linear-gradient(135deg, #FE304A 0%, #ff6b7a 100%);
}

body {
  font-family: "Noto Sans KR", sans-serif;
  color: var(--gray-800);
  line-height: 1.6;
  background: var(--receipt-bg);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* ===== Screen System ===== */
.screen {
  display: none;
  min-height: 100dvh;
  width: 100%;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
}

.screen.active {
  display: flex;
  animation: fadeIn 0.4s ease;
}

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

.screen-inner {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  text-align: center;
}

.screen-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 32px;
  color: var(--dark);
}

/* ===== Buttons ===== */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-width: 320px;
  padding: 16px 32px;
  background: var(--gradient-1);
  color: #fff;
  border: none;
  border-radius: 16px;
  font-family: inherit;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(254, 48, 74, 0.3);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  max-width: 280px;
  padding: 14px 24px;
  background: var(--gray-100);
  color: var(--gray-800);
  border: none;
  border-radius: 14px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

.btn-secondary:hover:not(:disabled) {
  background: var(--gray-200);
  transform: translateY(-1px);
}

.btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-width: 320px;
  padding: 14px 24px;
  background: #fff;
  color: var(--gray-800);
  border: 2px solid var(--gray-200);
  border-radius: 16px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s;
}

.btn-outline:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}

.btn-text {
  display: inline-block;
  padding: 12px 24px;
  background: none;
  color: var(--gray-600);
  border: none;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.btn-text:hover {
  color: var(--primary);
}

/* ===== Intro Screen ===== */
#screen-intro {
  background: var(--receipt-bg);
}

.intro-emojis {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-bottom: 40px;
}

.intro-emojis span {
  font-size: 36px;
  animation: bounce 2s ease infinite;
}

.intro-emojis span:nth-child(1) { animation-delay: 0s; }
.intro-emojis span:nth-child(2) { animation-delay: 0.2s; }
.intro-emojis span:nth-child(3) { animation-delay: 0.4s; }
.intro-emojis span:nth-child(4) { animation-delay: 0.6s; }
.intro-emojis span:nth-child(5) { animation-delay: 0.8s; }
.intro-emojis span:nth-child(6) { animation-delay: 1.0s; }

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.intro-title {
  font-size: 32px;
  font-weight: 800;
  line-height: 1.3;
  margin-bottom: 12px;
  color: var(--dark);
}

.intro-subtitle {
  font-size: 16px;
  color: var(--gray-600);
  margin-bottom: 40px;
}

.intro-credit {
  margin-top: 20px;
  font-size: 13px;
  color: var(--gray-600);
}

.woota-logo-img {
  height: 20px;
  width: auto;
  vertical-align: middle;
  border-radius: 4px;
  margin-left: 2px;
}

/* ===== Question Screen ===== */
#screen-question {
  background: #fff;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--gray-100);
  border-radius: 3px;
  margin-bottom: 32px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--gradient-1);
  border-radius: 3px;
  transition: width 0.4s ease;
  width: 0%;
}

.question-number {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 16px;
}

.question-text {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.5;
  margin-bottom: 32px;
  color: var(--dark);
  min-height: 60px;
}

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

.answer-btn {
  width: 100%;
  padding: 16px 20px;
  background: var(--gray-50);
  border: 2px solid var(--gray-200);
  border-radius: 14px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  color: var(--gray-800);
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
  line-height: 1.4;
}

@media (hover: hover) {
  .answer-btn:hover {
    border-color: var(--primary-light);
    background: #fff5f6;
  }
}

.answer-btn:active,
.answer-btn.selected {
  border-color: var(--primary);
  background: #fff0f2;
  color: var(--primary-dark);
  font-weight: 600;
}

/* ===== Ad Screen ===== */
#screen-ad {
  background: linear-gradient(180deg, #fff5f6 0%, #fff 100%);
}

.ad-card {
  background: #fff;
  border-radius: 24px;
  padding: 40px 24px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
}

.ad-logo {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  margin-bottom: 20px;
}

.ad-title {
  font-size: 24px;
  font-weight: 800;
  color: var(--dark);
  margin-bottom: 6px;
}

.ad-brand {
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 16px;
}

.ad-desc {
  font-size: 15px;
  color: var(--gray-600);
  line-height: 1.6;
  margin-bottom: 28px;
}

.ad-badges {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  margin-bottom: 24px;
}

.badge-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-width: 220px;
  padding: 12px 20px;
  border-radius: 12px;
  text-decoration: none;
  font-size: 15px;
  font-weight: 600;
  transition: transform 0.2s, box-shadow 0.2s;
}

.badge-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.badge-link--apple {
  background: #000;
  color: #fff;
}

.badge-link--google {
  background: #fff;
  color: var(--dark);
  border: 1.5px solid #e5e7eb;
}

#ad-countdown {
  font-size: 14px;
  opacity: 0.7;
}

/* ===== Calculating Screen ===== */
#screen-calculating {
  background: var(--receipt-bg);
}

.calc-emoji {
  font-size: 72px;
  margin-bottom: 24px;
  animation: spin 1.5s ease infinite;
}

@keyframes spin {
  0% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.15) rotate(10deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.calc-text {
  font-size: 20px;
  font-weight: 700;
  color: var(--dark);
  line-height: 1.5;
  margin-bottom: 20px;
}

.calc-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.calc-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  animation: dotPulse 1.2s ease infinite;
}

.calc-dots span:nth-child(2) { animation-delay: 0.2s; }
.calc-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

/* ===== Result Screen ===== */
#screen-result {
  background: var(--receipt-bg);
  padding-top: 32px;
  padding-bottom: 48px;
}

#screen-result .screen-inner {
  max-width: 380px;
}

/* ===== Receipt Card ===== */
.receipt-card {
  background: var(--receipt-paper);
  width: 100%;
  max-width: 340px;
  margin: 0 auto 24px;
  padding: 32px 24px;
  position: relative;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  transform: rotate(-1deg);
  border-top: 4px solid #ccc;
  font-family: "Courier New", "D2Coding", "Noto Sans KR", monospace;
}

/* 지그재그 상단 */
.receipt-card::before {
  content: "";
  position: absolute;
  top: -8px;
  left: 0;
  right: 0;
  height: 8px;
  background: linear-gradient(135deg, var(--receipt-bg) 33.33%, transparent 33.33%) 0 0,
              linear-gradient(225deg, var(--receipt-bg) 33.33%, transparent 33.33%) 0 0;
  background-size: 12px 8px;
  background-repeat: repeat-x;
}

/* 지그재그 하단 */
.receipt-card::after {
  content: "";
  position: absolute;
  bottom: -8px;
  left: 0;
  right: 0;
  height: 8px;
  background: linear-gradient(315deg, var(--receipt-bg) 33.33%, transparent 33.33%) 0 0,
              linear-gradient(45deg, var(--receipt-bg) 33.33%, transparent 33.33%) 0 0;
  background-size: 12px 8px;
  background-repeat: repeat-x;
}

/* 영수증 헤더 */
.receipt-header {
  text-align: center;
  margin-bottom: 16px;
}

.receipt-emoji {
  font-size: 40px;
  display: block;
  margin-bottom: 8px;
}

.receipt-store-name {
  font-size: 22px;
  font-weight: 800;
  color: var(--receipt-text);
  letter-spacing: 2px;
  margin-bottom: 2px;
}

.receipt-store-name-en {
  font-size: 11px;
  color: var(--receipt-light);
  letter-spacing: 3px;
  margin-bottom: 8px;
}

.receipt-date {
  font-size: 12px;
  color: var(--receipt-light);
}

/* 구분선 */
.receipt-divider {
  text-align: center;
  font-size: 12px;
  color: var(--receipt-light);
  letter-spacing: 2px;
  margin: 12px 0;
  overflow: hidden;
  user-select: none;
}

.receipt-divider-double {
  border: none;
  border-top: 2px double var(--receipt-light);
  margin: 12px 0;
  opacity: 0.4;
}

/* 항목 리스트 */
.receipt-items {
  margin: 8px 0;
}

.receipt-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 4px 0;
  font-size: 13px;
  color: var(--receipt-text);
  gap: 8px;
}

.receipt-item-name {
  flex: 1;
  text-align: left;
  word-break: keep-all;
}

.receipt-item-price {
  flex-shrink: 0;
  text-align: right;
  font-weight: 600;
  white-space: nowrap;
}

/* 합계 */
.receipt-total-section {
  margin-top: 8px;
}

.receipt-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 14px;
  color: var(--receipt-text);
}

.receipt-total-label {
  font-weight: 700;
  font-size: 15px;
}

.receipt-total-value {
  font-weight: 800;
  font-size: 18px;
}

/* 에너지 & 한마디 */
.receipt-footer {
  text-align: center;
  margin-top: 12px;
}

.receipt-energy-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 13px;
  color: var(--receipt-text);
}

.receipt-energy-label {
  font-weight: 600;
}

.receipt-energy-value {
  font-weight: 700;
  letter-spacing: 2px;
  color: #e8a500;
}

.receipt-comment {
  font-size: 13px;
  color: var(--receipt-text);
  font-weight: 600;
  margin-top: 16px;
  line-height: 1.6;
  font-style: italic;
}

/* 바코드 */
.receipt-barcode {
  margin-top: 20px;
  text-align: center;
}

.receipt-barcode-lines {
  display: flex;
  justify-content: center;
  gap: 2px;
  height: 40px;
  margin-bottom: 6px;
}

.receipt-barcode-lines span {
  display: inline-block;
  width: 2px;
  height: 100%;
  background: var(--receipt-text);
  opacity: 0.7;
}

.receipt-barcode-lines span:nth-child(even) {
  width: 1px;
  opacity: 0.4;
}

.receipt-barcode-lines span:nth-child(3n) {
  width: 3px;
  opacity: 0.6;
}

.receipt-barcode-text {
  font-size: 10px;
  color: var(--receipt-light);
  letter-spacing: 4px;
}

/* 워터마크 */
.receipt-watermark {
  font-size: 11px;
  color: var(--receipt-light);
  margin-top: 12px;
  opacity: 0.5;
}

/* ===== Result Actions ===== */
.result-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
}

/* ===== Download CTA ===== */
.download-cta {
  background: #fff;
  border-radius: 24px;
  padding: 32px 24px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  text-align: center;
}

.cta-logo {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  margin-bottom: 16px;
}

.cta-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--dark);
  line-height: 1.4;
  margin-bottom: 8px;
}

.cta-subtitle {
  font-size: 14px;
  color: var(--gray-600);
  margin-bottom: 24px;
}

.cta-badges {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--dark);
  color: #fff;
  padding: 14px 28px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 1000;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .intro-title {
    font-size: 26px;
  }

  .intro-emojis span {
    font-size: 28px;
  }

  .question-text {
    font-size: 18px;
  }

  .receipt-card {
    max-width: 310px;
    padding: 28px 20px;
  }
}

@media (max-width: 380px) {
  .screen {
    padding: 20px 16px;
  }

  .intro-title {
    font-size: 24px;
  }

  .receipt-card {
    max-width: 290px;
    padding: 24px 16px;
  }

  .receipt-store-name {
    font-size: 18px;
  }

  .receipt-item {
    font-size: 12px;
  }
}
