/* ==================== Reset & Base ==================== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
  color: #fff;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  padding: 0;
}

/* ==================== Pages ==================== */
.page {
  display: none;
  width: 100%;
  max-width: 420px;
  min-height: 100vh;
  padding: 24px 20px;
  position: relative;
  animation: fadeIn 0.4s ease;
}

.page.active {
  display: flex;
  flex-direction: column;
}

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

/* ==================== Start Page ==================== */
#page-start {
  justify-content: center;
  align-items: center;
  text-align: center;
}

.start-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.start-emoji {
  font-size: 80px;
  line-height: 1;
  animation: bounce 2s ease-in-out infinite;
}

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

.start-title {
  font-size: 32px;
  font-weight: 800;
  background: linear-gradient(135deg, #f093fb, #f5576c, #fda085);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 2px;
}

.start-subtitle {
  font-size: 16px;
  color: rgba(255,255,255,0.7);
  margin-top: -8px;
}

.start-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 8px 0;
}

.start-badges span {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
  color: rgba(255,255,255,0.85);
  backdrop-filter: blur(4px);
}

/* ==================== Buttons ==================== */
.btn-primary {
  background: linear-gradient(135deg, #f093fb, #f5576c);
  border: none;
  color: #fff;
  padding: 14px 48px;
  border-radius: 50px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 8px 24px rgba(245,87,108,0.4);
  letter-spacing: 1px;
}

.btn-primary:active {
  transform: scale(0.95);
  box-shadow: 0 4px 12px rgba(245,87,108,0.3);
}

.btn-secondary {
  background: linear-gradient(135deg, #667eea, #764ba2);
  border: none;
  color: #fff;
  padding: 12px 32px;
  border-radius: 50px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 6px 20px rgba(118,75,162,0.4);
}

.btn-secondary:active {
  transform: scale(0.95);
}

.btn-outline {
  background: transparent;
  border: 2px solid rgba(255,255,255,0.3);
  color: rgba(255,255,255,0.8);
  padding: 12px 32px;
  border-radius: 50px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s;
}

.btn-outline:active {
  transform: scale(0.95);
  border-color: rgba(255,255,255,0.6);
}

/* ==================== Quiz Page ==================== */
.quiz-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  padding-top: 8px;
}

.progress-bar {
  flex: 1;
  height: 8px;
  background: rgba(255,255,255,0.15);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #f093fb, #f5576c);
  border-radius: 4px;
  transition: width 0.5s ease;
}

.question-counter {
  font-size: 14px;
  color: rgba(255,255,255,0.6);
  white-space: nowrap;
  min-width: 48px;
  text-align: right;
}

.question-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding-top: 12px;
}

.question-emoji {
  font-size: 56px;
  text-align: center;
  margin-bottom: 16px;
  animation: float 3s ease-in-out infinite;
}

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

.question-text {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.5;
  margin-bottom: 28px;
  text-align: center;
  color: #fff;
}

/* ==================== Options ==================== */
.options-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.option-card {
  background: rgba(255,255,255,0.08);
  border: 2px solid rgba(255,255,255,0.12);
  border-radius: 16px;
  padding: 16px 18px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  gap: 12px;
  user-select: none;
  -webkit-user-select: none;
}

.option-card:hover {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.25);
}

.option-card:active {
  transform: scale(0.96);
  background: rgba(255,255,255,0.15);
}

.option-card.selected {
  border-color: #f5576c;
  background: rgba(245,87,108,0.15);
  transform: scale(0.96);
}

.option-card.disabled {
  pointer-events: none;
  opacity: 0.7;
}

.option-emoji {
  font-size: 28px;
  flex-shrink: 0;
}

.option-label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.3);
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  color: rgba(255,255,255,0.6);
  transition: all 0.2s;
}

.option-card.selected .option-label {
  background: #f5576c;
  border-color: #f5576c;
  color: #fff;
}

.option-text {
  font-size: 15px;
  line-height: 1.4;
  color: rgba(255,255,255,0.9);
}

/* Slide animation */
.slide-out-left {
  animation: slideOutLeft 0.35s ease forwards;
}

.slide-in-right {
  animation: slideInRight 0.35s ease forwards;
}

@keyframes slideOutLeft {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(-40px); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ==================== Result Page ==================== */
#page-result {
  justify-content: center;
  align-items: center;
}

.result-card {
  background: rgba(255,255,255,0.08);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 24px;
  padding: 32px 24px;
  text-align: center;
  width: 100%;
  animation: popIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popIn {
  0% { opacity: 0; transform: scale(0.8); }
  100% { opacity: 1; transform: scale(1); }
}

.result-emoji {
  font-size: 64px;
  margin-bottom: 12px;
  animation: bounce 2s ease-in-out infinite;
}

.result-badge {
  display: inline-block;
  padding: 6px 18px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 16px;
  background: linear-gradient(135deg, #f093fb33, #f5576c33);
  border: 1px solid rgba(245,87,108,0.3);
  color: #fda085;
}

.result-title {
  font-size: 26px;
  font-weight: 800;
  margin-bottom: 16px;
  background: linear-gradient(135deg, #f093fb, #f5576c, #fda085);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.result-desc {
  font-size: 15px;
  line-height: 1.7;
  color: rgba(255,255,255,0.8);
  margin-bottom: 24px;
  padding: 0 4px;
}

.result-stat {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.stat-label {
  font-size: 14px;
  color: rgba(255,255,255,0.5);
}

.stat-value {
  font-size: 36px;
  font-weight: 800;
  background: linear-gradient(135deg, #f093fb, #f5576c);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.result-compare {
  font-size: 14px;
  color: rgba(255,255,255,0.6);
  margin-bottom: 28px;
  padding: 8px 16px;
  background: rgba(255,255,255,0.05);
  border-radius: 12px;
  display: inline-block;
}

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

.result-actions .btn-secondary,
.result-actions .btn-outline {
  width: 100%;
}

/* ==================== Ad Container ==================== */
.ad-container {
  margin-top: 24px;
  padding: 16px;
  background: rgba(255,255,255,0.04);
  border: 1px dashed rgba(255,255,255,0.1);
  border-radius: 12px;
  text-align: center;
  width: 100%;
}

.ad-label {
  font-size: 12px;
  color: rgba(255,255,255,0.3);
}

/* ==================== Poster Overlay ==================== */
.poster-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn 0.3s ease;
}

.poster-overlay.hidden {
  display: none;
}

.poster-content {
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.poster-content canvas {
  display: block;
  width: 100%;
  height: auto;
}

.poster-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  max-width: 360px;
  width: 100%;
}

.poster-actions .btn-primary,
.poster-actions .btn-outline {
  flex: 1;
  text-align: center;
  padding: 12px 16px;
  font-size: 14px;
}

/* ==================== Responsive ==================== */
@media (max-width: 420px) {
  .page {
    padding: 20px 16px;
  }
  .start-title {
    font-size: 28px;
  }
  .start-emoji {
    font-size: 64px;
  }
  .question-text {
    font-size: 18px;
  }
  .result-title {
    font-size: 22px;
  }
  .stat-value {
    font-size: 30px;
  }
}

/* iPhone safe area */
@supports (padding-top: env(safe-area-inset-top)) {
  .page {
    padding-top: calc(24px + env(safe-area-inset-top));
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
  }
}
