:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  --bg-start: #6366f1;
  --bg-end: #8b5cf6;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --radius: 16px;
  --shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Segoe UI", "PingFang TC", "Microsoft JhengHei", sans-serif;
  background: linear-gradient(135deg, var(--bg-start), var(--bg-end));
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: var(--text);
  line-height: 1.5;
}

.app {
  width: 100%;
  max-width: 520px;
}

.container {
  background: var(--card-bg);
  border-radius: 24px;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform var(--transition);
}

/* 頁面 */
.page {
  display: none;
  padding: 32px 28px;
  text-align: center;
  animation: fadeIn 0.4s ease;
}

.page.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 起始頁 */
.logo {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 32px;
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
}

h1 {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.desc {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 28px;
}

.mode-buttons {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 20px;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  transition: all var(--transition);
  color: white;
  font-weight: 600;
}

.mode-btn i {
  font-size: 28px;
  margin-bottom: 4px;
}

.mode-btn span {
  font-size: 1.2rem;
}

.mode-btn small {
  font-size: 0.8rem;
  opacity: 0.85;
  font-weight: 400;
}

.mode-btn.expensive {
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  box-shadow: 0 8px 20px rgba(124, 58, 237, 0.35);
}

.mode-btn.cheap {
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
  box-shadow: 0 8px 20px rgba(14, 165, 233, 0.35);
}

.mode-btn:hover {
  transform: translateY(-3px);
  filter: brightness(1.05);
}

.mode-btn:active {
  transform: translateY(0);
}

/* 選擇頁 */
h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.hint {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 24px;
}

.image-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.glasses-card {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  background: #f8fafc;
  border: 3px solid transparent;
  transition: all var(--transition);
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.glasses-card:hover {
  border-color: #c7d2fe;
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(79, 70, 229, 0.15);
}

.glasses-card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.2);
}

.glasses-card.correct {
  border-color: var(--success);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.25);
}

.glasses-card.wrong {
  border-color: var(--error);
  animation: shake 0.4s ease;
}

.glasses-card.disabled {
  pointer-events: none;
  opacity: 0.7;
}

.glasses {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 12px;
  transition: transform var(--transition);
}

.glasses-card:hover .glasses {
  transform: scale(1.04);
}

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(16, 185, 129, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 36px;
  opacity: 0;
  transition: opacity var(--transition);
}

.glasses-card.correct .overlay {
  opacity: 1;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* 訊息 */
.message {
  margin: 16px 0;
  padding: 14px 18px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 1rem;
  display: none;
  animation: fadeIn 0.35s ease;
}

.message.show {
  display: block;
}

.message.success {
  background: #d1fae5;
  color: #065f46;
}

.message.error {
  background: #fee2e2;
  color: #991b1b;
}

.message.info {
  background: #e0e7ff;
  color: #3730a3;
}

/* 按鈕 */
.primary-btn {
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: white;
  border: none;
  padding: 14px 28px;
  border-radius: 12px;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.3);
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(79, 70, 229, 0.4);
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.5);
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.secondary-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: white;
}

/* 價格頁 */
.price-display {
  margin: 20px 0 28px;
  font-size: 2.8rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -1px;
}

.price-display .currency {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-left: 4px;
}

.price-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 28px;
}

.control-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: #f1f5f9;
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.control-btn:hover {
  background: #e2e8f0;
  transform: scale(1.08);
}

.control-btn:active {
  transform: scale(0.95);
}

#priceRange {
  flex: 1;
  height: 8px;
  -webkit-appearance: none;
  appearance: none;
  background: #e2e8f0;
  border-radius: 4px;
  outline: none;
}

#priceRange::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.4);
  transition: transform 0.15s;
}

#priceRange::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

#priceRange::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: none;
}

/* 恭喜頁 */
#correctPage {
  background: linear-gradient(160deg, #4f46e5 0%, #7c3aed 50%, #a855f7 100%);
  color: white;
  padding: 40px 28px;
}

.success-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 16px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  animation: bounce 1s ease infinite alternate;
}

@keyframes bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-8px); }
}

#correctPage h2 {
  color: white;
  font-size: 1.8rem;
  margin-bottom: 8px;
}

.correct-price {
  font-size: 1.2rem;
  opacity: 0.95;
  margin-bottom: 24px;
}

.correct-image-wrap {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  padding: 16px;
  margin-bottom: 24px;
  backdrop-filter: blur(8px);
}

.correct-image-wrap img {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  border-radius: 12px;
}

.countdown-wrap {
  margin-bottom: 8px;
}

.countdown {
  font-size: 4rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.countdown-wrap p {
  opacity: 0.85;
  font-size: 0.95rem;
}

/* Footer */
.footer {
  text-align: center;
  margin-top: 20px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.85rem;
}

/* 響應式 */
@media (max-width: 480px) {
  .page {
    padding: 24px 18px;
  }
  
  h1 {
    font-size: 1.9rem;
  }
  
  .price-display {
    font-size: 2.3rem;
  }
  
  .countdown {
    font-size: 3.2rem;
  }
  
  .image-container {
    gap: 12px;
  }
}