:root {
  --bg: #ffffff;
  --surface: #f5f5f5;
  --text: #333333;
  --muted-text: #666666;
  --primary: #2196F3;
  --accent: #FF9800;
  /* Brand CTA: points + add/redeem — vivid orange (not overridden by store primary) */
  --action: #FF731F;
  --border: #e0e0e0;
  --success: #4CAF50;
  --danger: #F44336;
  --overlay: rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] {
  --bg: #1a1a1a;
  --surface: #2d2d2d;
  --text: #ffffff;
  --muted-text: #b0b0b0;
  --border: #404040;
  --overlay: rgba(0, 0, 0, 0.7);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 16px;
}

.hidden {
  display: none !important;
}

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 16px;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.status-banner {
  background: var(--accent);
  color: #fff;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  text-align: center;
  font-weight: 500;
}

.status-banner.paused {
  background: var(--accent);
}

.status-banner.disabled {
  background: var(--danger);
}

.header {
  text-align: center;
  margin-bottom: 20px;
  position: relative;
}

.logo-slot {
  margin-bottom: 12px;
}

.logo {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface);
  border: 3px solid var(--border);
}

.logo-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 700;
  color: var(--muted-text);
  border: 2px dashed var(--border);
  letter-spacing: 0.02em;
}

.store-name {
  font-size: 20px;
  font-weight: 600;
}

.points-section {
  background: var(--surface);
  border-radius: 16px;
  padding: 20px;
  text-align: center;
  margin-bottom: 16px;
}

.points-label {
  font-size: 13px;
  color: var(--muted-text);
  margin-bottom: 6px;
}

.points-value {
  font-size: 40px;
  font-weight: 700;
  color: var(--action);
}

.rewards-scroll {
  margin-bottom: 16px;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  background: var(--bg);
}

.rewards-scroll.scrollable {
  max-height: min(260px, calc(100dvh - 300px));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.rewards-scroll.scrollable::-webkit-scrollbar {
  width: 6px;
}

.rewards-scroll.scrollable::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.rewards-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 0;
}

.reward-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  transition: border-color 0.3s;
}

.reward-card.complete {
  border-color: var(--success);
  background: linear-gradient(135deg, var(--surface) 0%, rgba(76, 175, 80, 0.1) 100%);
}

.reward-info {
  flex: 1;
}

.reward-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
}

.reward-progress {
  font-size: 13px;
  color: var(--muted-text);
  margin-bottom: 6px;
}

.progress-bar {
  width: 100%;
  height: 10px;
  background: var(--border);
  border-radius: 5px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--action) 0%, #FF9A55 100%);
  border-radius: 5px;
  transition: width 0.3s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.progress-fill.complete {
  background: linear-gradient(90deg, var(--success) 0%, #66BB6A 100%);
}

.btn-redeem {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
  background: var(--action);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.2s;
}

.btn-redeem:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-primary {
  width: 100%;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  color: #ffffff;
  background: var(--action);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  touch-action: manipulation;
  transition: opacity 0.2s;
}

.btn-primary:active {
  opacity: 0.8;
}

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

.btn-secondary {
  flex: 1;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  touch-action: manipulation;
}

.btn-secondary:active {
  opacity: 0.8;
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-content {
  background: var(--bg);
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.modal-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 20px;
  text-align: center;
}

.pin-input-wrapper {
  position: relative;
  margin-bottom: 16px;
}

#pinInput {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.pin-display {
  width: 100%;
  min-height: 60px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  letter-spacing: 8px;
  cursor: text;
  user-select: none;
}

.error-message {
  color: var(--danger);
  font-size: 14px;
  margin-bottom: 16px;
  text-align: center;
}

.modal-actions {
  display: flex;
  gap: 12px;
}

.success-icon {
  width: 80px;
  height: 80px;
  background: var(--success);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  margin: 0 auto 20px;
}

.success-points {
  font-size: 36px;
  font-weight: 700;
  color: var(--action);
  text-align: center;
  margin: 16px 0 24px;
}

.lang-switcher {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--muted-text);
}

.lang-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  color: var(--muted-text);
  padding: 2px 4px;
  border-radius: 4px;
}

.lang-btn.active {
  font-weight: 700;
  color: var(--accent);
}
