:root {
  --pokedex-red: #dc0a2d;
  --pokedex-red-dark: #a00821;
  --pokedex-red-light: #ee1f3f;
  --screen-bg: #f5efe0;
  --screen-border: #2a3140;
  --screen-shadow: rgba(0, 0, 0, 0.25);
  --pokedex-blue: #3b82f6;
  --pokedex-blue-light: #60a5fa;
  --pokedex-blue-glow: rgba(59, 130, 246, 0.4);
  --pokedex-yellow: #fbbf24;
  --pokedex-green: #22c55e;
  --pokedex-black: #1a1a2e;
  --pokedex-gray: #6b7280;
  --pokedex-cream: #fef9ec;
  --text-dark: #1a1a2e;
  --text-muted: #6b7280;
  --danger: #dc2626;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro", "Helvetica Neue",
    "Apple SD Gothic Neo", sans-serif;
  background: linear-gradient(135deg, var(--pokedex-red) 0%, var(--pokedex-red-dark) 100%);
  color: var(--text-dark);
  min-height: 100vh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
}

header {
  padding: 16px 16px 12px;
  position: relative;
  color: white;
}

.header-inner {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-left: 60px;
  padding-right: 40px;
}

.header-title {
  text-align: left;
  flex: 1;
  min-width: 0;
}

.header-account {
  flex-shrink: 0;
}

.header-account {
  display: flex;
  gap: 6px;
  align-items: center;
}

.account-btn, .user-chip {
  padding: 8px 14px;
  border-radius: 20px;
  border: 2px solid rgba(255, 255, 255, 0.6);
  background: rgba(0, 0, 0, 0.2);
  color: white;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 200px;
}

.account-btn.ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.4);
}

.user-chip #user-email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 130px;
}

.plan-badge {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--pokedex-yellow);
  color: var(--pokedex-black);
  letter-spacing: 0.5px;
}

.plan-badge.plan-pro {
  background: var(--pokedex-blue);
  color: white;
}

.plan-badge.plan-reseller {
  background: linear-gradient(135deg, #fbbf24, #dc0a2d);
  color: white;
}

/* --- Modal --- */
.modal[hidden] {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  cursor: pointer;
}

.modal-card {
  position: relative;
  z-index: 2;
  background: var(--pokedex-cream);
  border: 3px solid var(--screen-border);
  border-radius: 16px;
  padding: 24px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3), 0 4px 0 var(--pokedex-red-dark);
  pointer-events: auto;
}

.modal-card button {
  pointer-events: auto;
}

.modal-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--pokedex-black);
  background: white;
  font-size: 20px;
  font-weight: 800;
  color: var(--pokedex-black);
  cursor: pointer;
  font-family: inherit;
  line-height: 1;
  padding: 0;
}

.modal-tabs {
  display: flex;
  gap: 6px;
  background: var(--pokedex-black);
  padding: 5px;
  border-radius: 10px;
  margin-bottom: 20px;
}

.modal-tab {
  flex: 1;
  padding: 10px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.6);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

.modal-tab.active {
  background: var(--pokedex-red);
  color: white;
}

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

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--pokedex-red);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.auth-form input {
  padding: 12px 14px;
  border-radius: 8px;
  border: 2px solid var(--pokedex-black);
  background: white;
  font-size: 16px;
  font-family: inherit;
  color: var(--pokedex-black);
}

.auth-form input:focus {
  outline: none;
  border-color: var(--pokedex-blue);
  box-shadow: 0 0 0 3px var(--pokedex-blue-glow);
}

.auth-message {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

.auth-message.error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.auth-message.success {
  background: #dcfce7;
  color: #14532d;
  border: 1px solid #86efac;
}

.auth-footer {
  margin-top: 16px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}

.account-info {
  background: white;
  border: 2px solid var(--screen-border);
  border-radius: 10px;
  padding: 4px 14px;
  margin: 16px 0;
}

.account-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#user-panel .modal-card h3 {
  margin-bottom: 4px;
}

.scan-quota-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.scan-quota-label {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.scan-badge {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 6px;
  background: var(--pokedex-yellow);
  color: var(--pokedex-black);
  border: 1px solid var(--pokedex-black);
}

.scan-badge.warning {
  background: #fb923c;
  color: white;
}

.scan-badge.exceeded {
  background: var(--danger);
  color: white;
}

.scan-badge.unlimited {
  background: linear-gradient(135deg, #fbbf24, var(--pokedex-red));
  color: white;
  font-size: 16px;
}

.quota-card {
  text-align: center;
}

.quota-icon {
  font-size: 48px;
  margin-bottom: 8px;
}

.quota-card h3 {
  margin-bottom: 12px;
}

.quota-message {
  font-size: 14px;
  color: var(--text-dark);
  line-height: 1.6;
  margin-bottom: 20px;
}

.quota-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* --- Pricing Modal --- */
.pricing-card {
  max-width: 900px;
  padding: 24px;
}

.pricing-title {
  text-align: center;
  margin-bottom: 6px;
  font-size: 24px;
}

.pricing-sub {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 20px;
}

.pricing-billing-toggle {
  display: flex;
  gap: 4px;
  background: var(--pokedex-black);
  padding: 4px;
  border-radius: 10px;
  margin: 0 auto 24px;
  max-width: 320px;
}

.billing-tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.6);
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  border-radius: 6px;
  font-family: inherit;
}

.billing-tab.active {
  background: var(--pokedex-red);
  color: white;
}

.pricing-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

@media (min-width: 720px) {
  .pricing-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

.pricing-tier {
  background: white;
  border: 2px solid var(--screen-border);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  position: relative;
}

.pricing-tier.featured {
  border-color: var(--pokedex-red);
  border-width: 3px;
  box-shadow: 0 4px 0 var(--pokedex-red-dark);
}

.pricing-tier.current {
  background: var(--pokedex-cream);
  border-color: var(--pokedex-green);
}

.tier-badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--pokedex-red);
  color: white;
  font-size: 10px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 6px;
  letter-spacing: 0.5px;
}

.tier-name {
  font-size: 14px;
  font-weight: 800;
  color: var(--pokedex-red);
  text-transform: uppercase;
  letter-spacing: 1px;
  text-align: center;
  margin-bottom: 8px;
}

.tier-price {
  text-align: center;
  margin-bottom: 16px;
  color: var(--pokedex-black);
}

.tier-currency {
  font-size: 18px;
  font-weight: 700;
  vertical-align: top;
}

.tier-amount {
  font-size: 40px;
  font-weight: 900;
}

.tier-period {
  font-size: 13px;
  color: var(--text-muted);
  margin-left: 4px;
}

.tier-features {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
  flex: 1;
  font-size: 13px;
  line-height: 1.6;
}

.tier-features li {
  padding: 4px 0;
  color: var(--pokedex-black);
}

.tier-features li.muted {
  color: #cbd5e1;
}

.tier-btn {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  border: 2px solid var(--pokedex-black);
}

.tier-btn.primary {
  background: linear-gradient(180deg, var(--pokedex-red-light), var(--pokedex-red));
  color: white;
  border-color: var(--pokedex-red-dark);
  box-shadow: 0 3px 0 var(--pokedex-red-dark);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
}

.tier-btn.secondary {
  background: white;
  color: var(--pokedex-black);
  box-shadow: 0 2px 0 var(--pokedex-black);
}

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

.pricing-footnote {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* --- Pro Locked Feature --- */
.pro-locked {
  position: relative;
  overflow: hidden;
}

.pro-locked h3 {
  margin-bottom: 12px;
}

.pro-lock-overlay {
  text-align: center;
  padding: 24px 16px;
  background: linear-gradient(180deg, rgba(255, 203, 5, 0.1), rgba(220, 10, 45, 0.1));
  border: 2px dashed var(--pokedex-red);
  border-radius: 10px;
  margin-bottom: 10px;
}

.pro-lock-icon {
  font-size: 40px;
  margin-bottom: 8px;
}

.pro-lock-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--pokedex-red);
  margin-bottom: 6px;
}

.pro-lock-msg {
  font-size: 13px;
  color: var(--pokedex-black);
  line-height: 1.5;
  margin-bottom: 14px;
}

.pro-lock-preview {
  filter: blur(2px);
  opacity: 0.4;
  pointer-events: none;
}

header::before {
  content: "";
  position: absolute;
  top: 20px;
  left: 20px;
  width: 44px;
  height: 44px;
  background: radial-gradient(circle at 30% 30%, var(--pokedex-blue-light), var(--pokedex-blue) 60%, #1e40af);
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 0 20px var(--pokedex-blue-glow),
    inset 0 -3px 8px rgba(0, 0, 0, 0.3),
    inset 0 3px 6px rgba(255, 255, 255, 0.4);
  animation: blink 2.5s infinite ease-in-out;
}

header::after {
  content: "";
  position: absolute;
  top: 30px;
  right: 22px;
  width: 14px;
  height: 14px;
  background: radial-gradient(circle at 30% 30%, #ff6b6b, #dc2626);
  border: 2px solid rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(220, 38, 38, 0.6);
}

@keyframes blink {
  0%, 90%, 100% { opacity: 1; }
  95% { opacity: 0.4; }
}

header h1 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-shadow: 2px 2px 0 var(--pokedex-red-dark);
  white-space: nowrap;
}

.subtitle {
  color: rgba(255, 255, 255, 0.9);
  font-size: 12px;
  margin-top: 4px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Phones: not enough room for title + buttons on one line, so buttons get their own row. */
@media (max-width: 480px) {
  .header-inner {
    flex-wrap: wrap;
    row-gap: 8px;
    padding-right: 28px;
  }

  .header-title {
    flex: 1 0 100%;
  }

  header h1 {
    font-size: 20px;
  }

  .subtitle {
    display: none;
  }

  .account-btn, .user-chip {
    padding: 6px 12px;
    font-size: 12px;
  }
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 8px 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.mode-tabs {
  display: flex;
  gap: 6px;
  background: var(--pokedex-black);
  padding: 6px;
  border-radius: 12px;
  border: 3px solid var(--screen-border);
  box-shadow: 0 4px 0 var(--pokedex-red-dark);
}

.mode-tab {
  flex: 1;
  padding: 12px 16px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.6);
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  letter-spacing: 0.3px;
}

.mode-tab.active {
  background: linear-gradient(180deg, var(--pokedex-red-light), var(--pokedex-red));
  color: white;
  box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.big-entry {
  padding: 20px 16px;
  text-align: center;
}

.big-entry-title {
  font-size: 20px;
  color: var(--pokedex-red);
  margin-bottom: 8px;
  border: none;
  padding: 0;
}

.big-entry-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.5;
}

.big-input-row {
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
}

.big-input-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  max-width: 160px;
}

.big-input-wrap label {
  font-size: 12px;
  color: var(--pokedex-red);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.big-input-wrap input {
  width: 100%;
  padding: 20px 16px;
  border-radius: 12px;
  border: 3px solid var(--pokedex-black);
  background: var(--pokedex-cream);
  color: var(--pokedex-black);
  font-size: 36px;
  font-weight: 800;
  text-align: center;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
  -webkit-appearance: none;
}

.big-input-wrap input:focus {
  outline: none;
  border-color: var(--pokedex-blue);
  box-shadow: 0 0 0 4px var(--pokedex-blue-glow), inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.big-slash {
  font-size: 40px;
  color: var(--pokedex-red);
  padding-bottom: 20px;
  font-weight: 900;
}

.big-primary {
  width: 100%;
  padding: 18px 20px;
  font-size: 18px;
  font-weight: 800;
  border-radius: 12px;
  border: 3px solid var(--pokedex-red-dark);
  background: linear-gradient(180deg, var(--pokedex-red-light), var(--pokedex-red));
  color: white;
  cursor: pointer;
  box-shadow: 0 5px 0 var(--pokedex-red-dark), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  letter-spacing: 0.5px;
  font-family: inherit;
  transition: transform 0.05s ease, box-shadow 0.1s ease;
}

.big-primary:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--pokedex-red-dark);
}

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

.examples {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 2px dashed #cbd5e1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
}

.examples-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 700;
  margin-right: 4px;
}

.example-chip {
  padding: 8px 14px;
  border-radius: 20px;
  border: 2px solid var(--pokedex-red);
  background: white;
  color: var(--pokedex-red);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.1s ease;
}

.example-chip:hover, .example-chip:active {
  background: var(--pokedex-red);
  color: white;
}

#recent-scans h3 {
  margin-bottom: 10px;
}

#recent-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.recent-chip {
  padding: 10px 14px;
  border-radius: 8px;
  border: 2px solid var(--pokedex-black);
  background: var(--pokedex-cream);
  color: var(--pokedex-black);
  font-size: 14px;
  font-weight: 700;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  cursor: pointer;
  box-shadow: 0 2px 0 var(--pokedex-black);
  transition: transform 0.05s ease, box-shadow 0.1s ease;
}

.recent-chip:active {
  transform: translateY(2px);
  box-shadow: 0 0 0 var(--pokedex-black);
}

section {
  background: var(--pokedex-cream);
  border: 3px solid var(--screen-border);
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 4px 0 var(--pokedex-red-dark),
    0 6px 12px rgba(0, 0, 0, 0.2);
}

.video-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  background: #0a0a0a;
  border-radius: 8px;
  overflow: hidden;
  border: 4px solid var(--screen-border);
  box-shadow: inset 0 0 0 2px #4a5568,
    inset 0 4px 20px rgba(0, 0, 0, 0.5);
}

#video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#camera-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #22c55e;
  text-align: center;
  font-size: 14px;
  line-height: 1.6;
  background: #0a1f0a;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-weight: 600;
  text-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
  letter-spacing: 1px;
}

#camera-placeholder.hidden {
  display: none;
}

#card-guide {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.guide-frame {
  position: relative;
  width: 70%;
  aspect-ratio: 245 / 342;
  border: 3px dashed var(--pokedex-yellow);
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.4);
}

.guide-hint {
  position: absolute;
  top: -30px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  background: var(--pokedex-red);
  color: white;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.guide-number-hint {
  position: absolute;
  bottom: 12%;
  left: 8%;
  right: 8%;
  height: 12%;
  border: 2px solid var(--pokedex-yellow);
  border-radius: 6px;
  background: rgba(251, 191, 36, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--pokedex-yellow);
  font-weight: 800;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

button {
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  padding: 14px 20px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  letter-spacing: 0.3px;
  transition: transform 0.05s ease, box-shadow 0.1s ease;
}

button:active:not(:disabled) {
  transform: translateY(2px);
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

button.primary {
  background: linear-gradient(180deg, var(--pokedex-red-light), var(--pokedex-red));
  color: white;
  border: 2px solid var(--pokedex-red-dark);
  box-shadow: 0 4px 0 var(--pokedex-red-dark),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

button.primary:active:not(:disabled) {
  box-shadow: 0 2px 0 var(--pokedex-red-dark);
}

button.secondary {
  background: linear-gradient(180deg, #cbd5e1, #94a3b8);
  color: var(--text-dark);
  border: 2px solid var(--pokedex-black);
  box-shadow: 0 4px 0 var(--pokedex-black),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

button.secondary:active:not(:disabled) {
  box-shadow: 0 2px 0 var(--pokedex-black);
}

h2, h3, h4 {
  color: var(--pokedex-red);
  font-weight: 800;
  letter-spacing: 0.3px;
}

h2 {
  font-size: 16px;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--pokedex-red);
}

h3 {
  font-size: 15px;
  margin-bottom: 10px;
}

h4 {
  font-size: 18px;
  margin-bottom: 12px;
}

#canvas {
  width: 100%;
  height: auto;
  border-radius: 8px;
  border: 4px solid var(--screen-border);
  background: #000;
}

.hint {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 10px;
  text-align: center;
  line-height: 1.5;
}

#status {
  padding: 12px 16px;
  background: var(--screen-border);
  border-radius: 10px;
  border: 3px solid var(--pokedex-black);
  text-align: center;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.4);
}

#status-text {
  font-size: 12px;
  color: #22c55e;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
}

#status.error {
  border-color: var(--danger);
  background: #4a1010;
}
#status.error #status-text {
  color: #fca5a5;
  text-shadow: 0 0 6px rgba(220, 38, 38, 0.5);
}

#status.success {
  border-color: var(--pokedex-green);
  background: #052e14;
}
#status.success #status-text {
  color: #86efac;
}

#ocr-progress {
  margin-top: 14px;
  padding: 14px;
  background: white;
  border-radius: 10px;
  border: 2px solid var(--screen-border);
}

.progress-bar {
  width: 100%;
  height: 12px;
  background: #e5e7eb;
  border: 2px solid var(--pokedex-black);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 8px;
}

#progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--pokedex-yellow), var(--pokedex-red));
  transition: width 0.3s ease;
}

#progress-text {
  font-size: 12px;
  color: var(--text-dark);
  text-align: center;
  font-weight: 600;
}

#ocr-result {
  margin-top: 16px;
}

.info-card {
  background: white;
  border: 2px solid var(--screen-border);
  border-radius: 10px;
  padding: 4px 14px;
  margin-bottom: 12px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px dashed #cbd5e1;
}

.info-row:last-child {
  border-bottom: none;
}

.info-row .label {
  color: var(--pokedex-red);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.info-row .value {
  font-size: 17px;
  font-weight: 800;
  color: var(--pokedex-black);
  font-family: "SF Mono", Menlo, Consolas, monospace;
  background: var(--pokedex-yellow);
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid var(--pokedex-black);
}

details {
  background: white;
  border: 2px solid var(--screen-border);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 12px;
}

details summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--pokedex-red);
  font-weight: 700;
  user-select: none;
  letter-spacing: 0.3px;
}

details[open] summary {
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px dashed #cbd5e1;
}

pre {
  background: var(--pokedex-black);
  color: #22c55e;
  padding: 12px;
  border-radius: 6px;
  font-size: 11px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  max-height: 200px;
  overflow-y: auto;
}

.lookup-form {
  background: white;
  border: 2px solid var(--screen-border);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
}

.input-row {
  display: flex;
  align-items: end;
  gap: 12px;
  margin-bottom: 14px;
}

.input-row label {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--pokedex-red);
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.input-row .slash {
  font-size: 22px;
  color: var(--pokedex-red);
  padding-bottom: 12px;
  font-weight: 700;
}

.input-row input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 6px;
  border: 2px solid var(--pokedex-black);
  background: var(--pokedex-cream);
  color: var(--text-dark);
  font-size: 18px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  text-align: center;
  font-weight: 800;
}

.input-row input:focus {
  outline: none;
  border-color: var(--pokedex-blue);
  box-shadow: 0 0 0 3px var(--pokedex-blue-glow);
}

#lookup-loading {
  margin-top: 14px;
  padding: 24px;
  text-align: center;
  background: white;
  border: 2px solid var(--screen-border);
  border-radius: 10px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 4px solid #e5e7eb;
  border-top-color: var(--pokedex-red);
  border-right-color: var(--pokedex-red);
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: spin 0.8s linear infinite;
}

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

#lookup-results,
#card-detail {
  margin-top: 16px;
}

/* These headings sit directly on the red background. */
#lookup-results > h3,
#card-detail > h3,
.detail-info > h4 {
  color: white;
  text-shadow: 1px 1px 0 var(--pokedex-red-dark);
}

#cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.card-item {
  background: white;
  border: 2px solid var(--screen-border);
  border-radius: 10px;
  padding: 8px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 3px 0 var(--pokedex-black);
}

.card-item:hover,
.card-item:active {
  border-color: var(--pokedex-red);
  transform: translateY(-2px);
  box-shadow: 0 5px 0 var(--pokedex-red-dark);
}

.card-item img {
  width: 100%;
  border-radius: 6px;
  display: block;
  background: #000;
  aspect-ratio: 245 / 342;
  object-fit: contain;
}

.card-item-info {
  padding: 8px 4px 4px;
}

.card-item-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--pokedex-black);
  line-height: 1.3;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.card-item-set {
  font-size: 11px;
  color: var(--pokedex-red);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-item-meta {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-weight: 600;
}

.detail-layout {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
}

@media (min-width: 600px) {
  .detail-layout {
    flex-direction: row;
  }
  .detail-image {
    width: 240px;
    flex-shrink: 0;
    align-self: flex-start;
  }
  .detail-info {
    flex: 1;
    min-width: 0;
  }
}

.detail-image {
  width: 100%;
  max-width: 300px;
  height: auto;
  aspect-ratio: 245 / 342;
  object-fit: contain;
  margin: 0 auto;
  border-radius: 10px;
  border: 3px solid var(--screen-border);
  background: #000;
  align-self: center;
}

.value-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--pokedex-black);
  text-align: right;
}

.fallback-wrap {
  grid-column: 1 / -1;
  background: white;
  border: 2px solid var(--screen-border);
  border-radius: 10px;
  padding: 14px;
}

.fallback-hint {
  grid-column: 1 / -1;
  margin-top: 8px;
}

.links-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.link-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(180deg, white, #f1f5f9);
  border: 2px solid var(--pokedex-black);
  border-radius: 8px;
  color: var(--pokedex-black);
  text-decoration: none;
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 3px 0 var(--pokedex-black);
  transition: transform 0.05s ease, box-shadow 0.1s ease, border-color 0.1s ease;
}

.link-btn:hover,
.link-btn:active {
  border-color: var(--pokedex-red);
  color: var(--pokedex-red);
}

.link-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--pokedex-black);
}

.link-name {
  flex: 1;
}

.link-note {
  font-size: 11px;
  font-weight: 700;
  color: white;
  padding: 3px 8px;
  background: var(--pokedex-red);
  border-radius: 4px;
  letter-spacing: 0.3px;
}

.link-arrow {
  color: var(--pokedex-red);
  font-size: 20px;
  font-weight: 900;
}

.prices-section {
  margin-top: 16px;
  padding: 14px;
  background: white;
  border: 2px solid var(--screen-border);
  border-radius: 10px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

.prices-section h3 {
  margin-bottom: 12px;
}

.price-source {
  background: var(--pokedex-cream);
  border: 2px solid var(--pokedex-red);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
}

.price-source:last-child {
  margin-bottom: 0;
}

.price-source-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 2px dashed var(--pokedex-red);
}

.price-source-name {
  font-weight: 800;
  color: var(--pokedex-red);
  font-size: 14px;
  letter-spacing: 0.3px;
}

.price-source-currency {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: white;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid var(--pokedex-black);
}

.price-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px dotted #cbd5e1;
}

.price-row:last-of-type {
  border-bottom: none;
}

.price-label {
  font-size: 12px;
  color: var(--text-dark);
  font-weight: 600;
}

.price-values {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.price-market {
  font-size: 18px;
  font-weight: 800;
  color: var(--pokedex-black);
  font-family: "SF Mono", Menlo, Consolas, monospace;
  background: var(--pokedex-yellow);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--pokedex-black);
}

.price-range {
  font-size: 11px;
  color: var(--text-muted);
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-weight: 600;
}

.price-updated {
  font-size: 10px;
  color: var(--text-muted);
  text-align: right;
  margin-top: 6px;
  font-style: italic;
}

.price-links-section {
  margin-top: 16px;
}

.price-links-section h3 {
  margin-bottom: 10px;
}

.ebay-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.ebay-item {
  display: flex;
  gap: 10px;
  padding: 8px;
  background: white;
  border: 2px solid var(--pokedex-black);
  border-radius: 8px;
  text-decoration: none;
  color: var(--pokedex-black);
  transition: transform 0.05s ease, border-color 0.15s ease;
}

.ebay-item:hover, .ebay-item:active {
  border-color: var(--pokedex-red);
  transform: translateY(-1px);
}

.ebay-item img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
  flex-shrink: 0;
}

.ebay-item-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.ebay-item-title {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.ebay-item-price {
  font-size: 14px;
  font-weight: 800;
  color: var(--pokedex-red);
  font-family: "SF Mono", Menlo, Consolas, monospace;
  align-self: flex-end;
}

/* ===== Sell listing generator ===== */
.listing-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.listing-section .listing-head h3 {
  margin-bottom: 0;
}

.listing-lang {
  display: flex;
  border: 2px solid var(--pokedex-black);
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
}

.listing-lang-btn {
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  background: white;
  color: var(--pokedex-black);
  border: none;
  cursor: pointer;
}

.listing-lang-btn.active {
  background: var(--pokedex-black);
  color: white;
}

.listing-hint {
  text-align: left;
  margin: 0 0 10px;
}

.listing-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.listing-tab {
  flex: 1;
  min-width: 80px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 700;
  background: var(--pokedex-cream);
  color: var(--pokedex-black);
  border: 2px solid var(--pokedex-black);
  border-radius: 8px;
  cursor: pointer;
}

.listing-tab.active {
  background: var(--pokedex-red);
  color: white;
  border-color: var(--pokedex-red-dark);
}

.listing-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.listing-section label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dark);
}

.listing-section select,
.listing-section input,
.listing-section textarea {
  width: 100%;
  padding: 8px 10px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text-dark);
  background: white;
  border: 2px solid var(--screen-border);
  border-radius: 8px;
}

.listing-suggestion {
  margin: 8px 0 10px;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.listing-notes {
  margin-bottom: 12px;
}

.listing-output {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 12px;
  border-top: 2px dashed var(--pokedex-red);
}

.listing-output-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 800;
  margin-top: 4px;
}

.listing-output-head span:first-child {
  flex: 1;
}

.listing-count {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  color: var(--text-muted);
}

.listing-copy {
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 700;
  background: var(--pokedex-yellow);
  color: var(--pokedex-black);
  border: 2px solid var(--pokedex-black);
  border-radius: 6px;
  cursor: pointer;
}

.listing-section textarea[readonly],
.listing-section input[readonly] {
  background: var(--pokedex-cream);
  font-size: 13px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  resize: vertical;
}
