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

:root {
  --bg: #08080c;
  --bg2: #111118;
  --bg3: #1a1a24;
  --text: #e8e8ef;
  --text2: #8888a0;
  --accent: #a855f7;
  --accent2: #7c3aed;
  --gold: #f59e0b;
  --green: #22c55e;
  --blue: #3b82f6;
  --red: #ef4444;
  --border: #2a2a3a;
  --card: #13131d;
  --radius: 16px;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.hidden { display: none !important; }

/* HEADER */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  flex-shrink: 0;
}

#logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

#logo-icon {
  font-size: 22px;
  color: var(--accent);
  text-shadow: 0 0 20px var(--accent);
}

#logo-text {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 2px;
  background: linear-gradient(135deg, var(--accent), #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#wallet-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 24px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

#wallet-btn:hover {
  border-color: var(--accent);
  background: rgba(168, 85, 247, 0.1);
}

#wallet-btn.connected {
  border-color: var(--green);
  background: rgba(34, 197, 94, 0.1);
}

#wallet-btn.connected #wallet-icon { color: var(--green); }

#wallet-icon {
  font-size: 16px;
  color: var(--accent);
}

/* SCREENS */
.screen {
  display: none;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

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

/* BACK BUTTON */
.back-btn {
  position: sticky;
  top: 0;
  background: var(--bg);
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--accent);
  font-size: 15px;
  font-weight: 500;
  padding: 12px 16px;
  cursor: pointer;
  text-align: left;
  z-index: 10;
}

/* HERO */
#hero {
  text-align: center;
  padding: 60px 24px 40px;
  position: relative;
  overflow: hidden;
}

#hero-glow {
  position: absolute;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(168,85,247,0.15) 0%, transparent 70%);
  pointer-events: none;
}

#hero-diamond {
  font-size: 56px;
  color: var(--accent);
  text-shadow: 0 0 40px var(--accent), 0 0 80px rgba(168,85,247,0.3);
  margin-bottom: 20px;
  animation: float 3s ease-in-out infinite;
}

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

#hero h1 {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 12px;
  background: linear-gradient(to bottom, #fff, #aaa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#hero > p {
  font-size: 15px;
  color: var(--text2);
  max-width: 340px;
  margin: 0 auto 28px;
  line-height: 1.5;
}

#scan-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white;
  border: none;
  border-radius: 28px;
  padding: 16px 32px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 24px rgba(168, 85, 247, 0.4);
  transition: all 0.2s;
}

#scan-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 32px rgba(168, 85, 247, 0.5);
}

#manual-btn {
  display: block;
  background: none;
  border: none;
  color: var(--text2);
  font-size: 13px;
  margin: 12px auto 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

#manual-btn:hover { color: var(--text); }

/* HOW IT WORKS */
#how-it-works {
  padding: 40px 24px;
}

#how-it-works h2, #rarity-section h2 {
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 24px;
  color: var(--text);
}

.steps {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.step {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  text-align: center;
  flex: 1;
  min-width: 140px;
  max-width: 200px;
}

.step-icon {
  font-size: 32px;
  margin-bottom: 12px;
}

.step h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 6px;
}

.step p {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.4;
}

/* RARITY */
#rarity-section {
  padding: 20px 24px 120px;
}

.rarity-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 400px;
  margin: 0 auto;
}

.rarity-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
}

.rarity-badge {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1.5px;
  padding: 4px 10px;
  border-radius: 6px;
}

.rarity-card.legendary .rarity-badge { color: #ffd700; background: rgba(255,215,0,0.12); }
.rarity-card.epic .rarity-badge { color: #a855f7; background: rgba(168,85,247,0.12); }
.rarity-card.rare .rarity-badge { color: #3b82f6; background: rgba(59,130,246,0.12); }
.rarity-card.uncommon .rarity-badge { color: #22c55e; background: rgba(34,197,94,0.12); }
.rarity-card.common .rarity-badge { color: #9ca3af; background: rgba(156,163,175,0.12); }

.rarity-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.rarity-chance {
  font-size: 12px;
  color: var(--text2);
}

/* SCANNER */
#scanner-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
}

#reader {
  width: 100%;
  max-width: 400px;
  border-radius: var(--radius);
  overflow: hidden;
}

#reader video {
  border-radius: var(--radius);
}

#scanner-frame {
  position: absolute;
  width: 280px;
  height: 180px;
  z-index: 10;
  pointer-events: none;
}

.corner {
  position: absolute;
  width: 24px;
  height: 24px;
  border-color: var(--accent);
  border-style: solid;
  border-width: 0;
}

.corner.tl { top: 0; left: 0; border-top-width: 3px; border-left-width: 3px; border-radius: 6px 0 0 0; }
.corner.tr { top: 0; right: 0; border-top-width: 3px; border-right-width: 3px; border-radius: 0 6px 0 0; }
.corner.bl { bottom: 0; left: 0; border-bottom-width: 3px; border-left-width: 3px; border-radius: 0 0 0 6px; }
.corner.br { bottom: 0; right: 0; border-bottom-width: 3px; border-right-width: 3px; border-radius: 0 0 6px 0; }

#scan-line {
  position: absolute;
  top: 10%;
  left: 10%;
  right: 10%;
  height: 2px;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
  animation: scanMove 2s ease-in-out infinite;
}

@keyframes scanMove {
  0%, 100% { top: 10%; }
  50% { top: 85%; }
}

#scanner-hint {
  margin-top: 20px;
  font-size: 14px;
  color: var(--text2);
  z-index: 10;
}

#manual-entry {
  display: flex;
  gap: 10px;
  padding: 20px 24px;
  max-width: 420px;
  width: 100%;
  margin: 0 auto;
}

#manual-entry input {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 15px;
  outline: none;
}

#manual-entry input:focus { border-color: var(--accent); }

#manual-entry button, #upc-submit {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

/* ART REVEAL */
#art-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px;
  gap: 24px;
  padding-bottom: 100px;
}

#art-frame {
  width: 100%;
  max-width: 400px;
  aspect-ratio: 1;
  border-radius: 20px;
  overflow: hidden;
  border: 2px solid var(--border);
  background: var(--bg2);
  position: relative;
  animation: artReveal 0.8s ease-out;
}

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

#art-display {
  width: 100%;
  height: 100%;
}

#art-display svg {
  width: 100%;
  height: 100%;
  display: block;
}

#art-info {
  width: 100%;
  max-width: 400px;
  text-align: center;
}

#art-name {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 4px;
}

#art-upc-display {
  font-size: 13px;
  color: var(--text2);
  font-family: 'SF Mono', 'Fira Code', monospace;
  margin-bottom: 12px;
}

#art-rarity {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
}

#rarity-badge-display {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1.5px;
  padding: 4px 12px;
  border-radius: 6px;
}

#rarity-edition {
  font-size: 13px;
  color: var(--text2);
}

/* MINT PROGRESS */
#mint-progress {
  margin-bottom: 16px;
}

#mint-progress-bar {
  height: 8px;
  background: var(--bg3);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}

#mint-progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
  background: linear-gradient(90deg, var(--accent), var(--green));
}

#mint-progress-text {
  font-size: 13px;
  color: var(--text2);
}

#mint-btn {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white;
  border: none;
  border-radius: 16px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(168,85,247,0.3);
  transition: all 0.2s;
}

#mint-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 28px rgba(168,85,247,0.4);
}

#mint-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

#mint-btn.minted {
  background: linear-gradient(135deg, var(--green), #16a34a);
  box-shadow: 0 4px 20px rgba(34,197,94,0.3);
}

#mint-status {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text2);
}

#mint-status a {
  color: var(--accent);
  text-decoration: underline;
}

/* LOOKUP */
#lookup-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 24px;
}

#lookup-container h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
}

#lookup-container > p {
  font-size: 14px;
  color: var(--text2);
  margin-bottom: 24px;
}

#lookup-input-wrap {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 400px;
  margin-bottom: 24px;
}

#lookup-input-wrap input {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 15px;
  outline: none;
}

#lookup-input-wrap input:focus { border-color: var(--accent); }

#lookup-input-wrap button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

#lookup-result {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}

#lookup-result .lookup-art {
  width: 200px;
  height: 200px;
  margin: 0 auto 16px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
}

#lookup-result .lookup-art svg {
  width: 100%;
  height: 100%;
}

#lookup-result .lookup-name {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

#lookup-result .lookup-rarity {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1.5px;
  padding: 4px 12px;
  border-radius: 6px;
  display: inline-block;
  margin-bottom: 12px;
}

#lookup-result .lookup-mints {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 4px;
}

#lookup-result .lookup-mints-label {
  font-size: 13px;
  color: var(--text2);
}

#lookup-result .lookup-bar {
  height: 8px;
  background: var(--bg3);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 12px;
}

#lookup-result .lookup-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), var(--green));
}

#lookup-result .lookup-scan-btn {
  margin-top: 16px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

/* TOAST */
#toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  z-index: 1000;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  animation: toastIn 0.3s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* NAV */
#nav {
  display: flex;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding: 8px 0;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  flex-shrink: 0;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--text2);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px;
  transition: color 0.15s;
}

.nav-btn.active { color: var(--accent); }
.nav-btn:hover { color: var(--text); }

.nav-btn svg { stroke: currentColor; }

/* RESPONSIVE */
@media (min-width: 768px) {
  #hero { padding: 80px 40px 60px; }
  #hero h1 { font-size: 36px; }

  #art-container {
    flex-direction: row;
    justify-content: center;
    align-items: flex-start;
    gap: 40px;
    padding: 40px;
  }

  #art-frame { max-width: 450px; }
  #art-info { text-align: left; max-width: 350px; }
}

/* Rarity glow animation for art frame */
#art-frame.legendary { border-color: #ffd700; box-shadow: 0 0 30px rgba(255,215,0,0.3); }
#art-frame.epic { border-color: #a855f7; box-shadow: 0 0 30px rgba(168,85,247,0.3); }
#art-frame.rare { border-color: #3b82f6; box-shadow: 0 0 30px rgba(59,130,246,0.3); }
#art-frame.uncommon { border-color: #22c55e; box-shadow: 0 0 20px rgba(34,197,94,0.2); }
#art-frame.common { border-color: #4b5563; }

@keyframes glow {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.1); }
}

#art-frame.legendary, #art-frame.epic {
  animation: glow 2s ease-in-out infinite;
}

/* PRODUCT INFO */
#product-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 12px;
}

.product-icon { font-size: 16px; }

.product-name {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}

.product-loading {
  font-size: 13px;
  color: var(--text2);
  font-style: italic;
}

/* RARITY BREAKDOWN */
#rarity-breakdown, .lookup-breakdown {
  width: 100%;
  margin: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rarity-component {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rc-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.rc-icon { font-size: 14px; }

.rc-name {
  flex: 1;
  color: var(--text2);
  font-weight: 500;
}

.rc-score {
  font-weight: 700;
  font-size: 13px;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.rc-bar {
  height: 4px;
  background: var(--bg3);
  border-radius: 2px;
  overflow: hidden;
}

.rc-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.6s ease;
}

.lookup-breakdown {
  margin-top: 16px;
  text-align: left;
}
