/* ==================== STREET STYLE — NOFINEDINING ==================== */
@import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&display=swap');

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

:root {
  --bg: #0a0a0a;
  --bg2: #111;
  --bg3: #1a1a1a;
  --text: #f0ede8;
  --text2: #6b6762;
  --accent: #ff6b35;
  --accent-dim: rgba(255,107,53,0.1);
  --border: rgba(255,255,255,0.08);
  --mono: 'Space Mono', 'SF Mono', monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  --r: 3px;
}

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
}

#app { max-width: 480px; margin: 0 auto; min-height: 100dvh; position: relative; overflow-x: hidden; }

/* ==================== SCREENS ==================== */
.screen { display: none; opacity: 0; transition: opacity 0.3s ease; }
.screen.active { display: flex; flex-direction: column; opacity: 1; min-height: 100dvh; }

/* ==================== WELCOME ==================== */
#welcome { justify-content: center; padding: 48px 24px; }
.welcome-content { animation: fadeInUp 0.5s ease; }

.welcome-top {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 24px;
}

.barista-avatar {
  width: 100px;
  height: 100px;
  border-radius: var(--r);
  overflow: hidden;
  border: 2px solid var(--accent);
  flex-shrink: 0;
}
.barista-avatar img { width: 100%; height: 100%; object-fit: cover; }
.barista-avatar.small { width: 56px; height: 56px; }
.barista-avatar.tiny { width: 32px; height: 32px; }

.welcome-text { padding-top: 4px; }

.brand-tag {
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.2em;
  margin-bottom: 8px;
}

h1 {
  font-size: 2.4rem;
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: -0.04em;
  color: var(--text);
}

.subtitle {
  font-size: 0.9rem;
  color: var(--text2);
  line-height: 1.5;
  margin-bottom: 32px;
  max-width: 320px;
}

/* ==================== INPUTS ==================== */
.input-group {
  display: flex;
  gap: 0;
  width: 100%;
  max-width: 320px;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  transition: border-color 0.2s;
}

.input-group:focus-within {
  border-color: var(--accent);
}

.input-group input {
  flex: 1;
  background: var(--bg2);
  border: none;
  outline: none;
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.input-group input::placeholder {
  color: var(--text2);
  opacity: 0.5;
}

.input-group button {
  padding: 14px 20px;
  background: var(--accent);
  border: none;
  color: var(--bg);
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.06em;
  transition: background 0.2s;
}

.input-group button:hover { background: #ff8555; }

/* Lock */
.lock-icon {
  width: 48px; height: 48px;
  position: relative;
  margin-bottom: 20px;
}
.lock-ring {
  position: absolute;
  inset: -6px;
  border: 2px solid var(--border);
  border-radius: 50%;
  transition: all 0.6s ease;
}
.lock-icon.unlocked .lock-ring {
  border-color: var(--accent);
  animation: pulseRing 1s ease;
}
.lock-icon svg { width: 100%; height: 100%; position: absolute; top: 0; left: 0; transition: all 0.5s ease; }
.lock-icon .lock-open { opacity: 0; transform: scale(0.8); }
.lock-icon.unlocked .lock-closed { opacity: 0; transform: scale(0.8) rotate(-20deg); }
.lock-icon.unlocked .lock-open { opacity: 1; transform: scale(1); }
.lock-icon.shake { animation: shake 0.4s ease; }

.referral-gate { display: flex; flex-direction: column; align-items: flex-start; gap: 16px; }
.referral-gate.hidden { display: none; }

.referral-error {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: #ff3b30;
  font-weight: 700;
  letter-spacing: 0.06em;
  opacity: 0;
  transition: opacity 0.3s;
}
.referral-error.visible { opacity: 1; }

.name-gate { display: none; flex-direction: column; align-items: flex-start; gap: 16px; animation: fadeInUp 0.4s ease; }
.name-gate.visible { display: flex; }
.name-prompt { font-family: var(--mono); font-size: 0.75rem; color: var(--text2); font-weight: 700; letter-spacing: 0.1em; }

.referral-success { display: none; flex-direction: column; align-items: flex-start; gap: 20px; animation: fadeInUp 0.4s ease; }
.referral-success.visible { display: flex; }
.success-text { font-size: 1.4rem; font-weight: 800; color: var(--accent); letter-spacing: -0.02em; }

/* ==================== BUTTONS ==================== */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 16px 40px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--r);
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.1em;
  text-decoration: none;
  transition: all 0.2s;
}
.btn-primary:hover { background: #ff8555; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text2);
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  padding: 10px 16px;
  transition: all 0.2s;
}
.back-btn:hover { border-color: var(--text); color: var(--text); }
#backBtn { position: absolute; bottom: 20px; left: 20px; }

/* ==================== PROGRESS BLOCKS ==================== */
.progress-blocks {
  display: flex;
  gap: 4px;
  padding: 20px 24px 16px;
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(10,10,10,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.progress-blocks .block {
  flex: 1;
  height: 4px;
  background: var(--bg3);
  border-radius: 0;
  transition: background 0.3s;
}

.progress-blocks .block.active {
  background: var(--accent);
}

/* ==================== QUIZ ==================== */
#quiz { position: relative; padding-bottom: 80px; }
.quiz-container { padding: 28px 24px; overflow: hidden; }

.question { display: none; animation: slideIn 0.35s ease; }
.question.active { display: block; }
.question.slide-out { animation: slideOut 0.25s ease forwards; }

.question-header {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin-bottom: 8px;
}

.question-num {
  font-family: var(--mono);
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.question-total {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--text2);
  font-weight: 400;
}

.question h2 {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 24px;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

/* ==================== GRID TILES ==================== */
.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px 12px;
  background: var(--bg2);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  cursor: pointer;
  transition: all 0.2s;
  min-height: 100px;
}

.tile:hover {
  border-color: rgba(255,255,255,0.15);
  background: var(--bg3);
}

.tile:active { transform: scale(0.97); }

.tile.selected {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.tile-icon {
  width: 32px;
  height: 32px;
  color: var(--text2);
  transition: color 0.2s;
}

.tile-icon svg { width: 100%; height: 100%; }

.tile.selected .tile-icon { color: var(--accent); }

.tile-text {
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.06em;
  text-align: center;
}

/* Last tile centered if odd */
.options-grid .tile:last-child:nth-child(odd) {
  grid-column: 1 / -1;
  max-width: calc(50% - 4px);
  justify-self: center;
}

/* ==================== ANALYSIS ==================== */
#analysis { justify-content: center; align-items: center; padding: 60px 24px; text-align: center; }
.analysis-content { animation: fadeInUp 0.5s ease; }

.brew-animation {
  position: relative;
  width: 100px;
  height: 100px;
  margin: 0 auto 36px;
}

.brew-ring {
  position: absolute;
  inset: -8px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  animation: pulseRing 2s ease infinite;
}

.brew-ring.ring-2 {
  inset: -20px;
  border-color: rgba(255,107,53,0.3);
  animation-delay: 0.5s;
}

.brew-animation .barista-avatar {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

.analysis-content h2 {
  font-family: var(--mono);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.15em;
  margin-bottom: 40px;
}

.analysis-bars {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 280px;
  margin: 0 auto;
  text-align: left;
}

.analysis-bar {
  opacity: 0.2;
  transition: opacity 0.4s;
}

.analysis-bar.active { opacity: 1; }

.analysis-bar span {
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--text2);
  letter-spacing: 0.1em;
  display: block;
  margin-bottom: 6px;
}

.analysis-bar.active span { color: var(--text); }

.bar-fill {
  height: 3px;
  background: var(--bg3);
  border-radius: 0;
  overflow: hidden;
  position: relative;
}

.bar-fill::after {
  content: '';
  position: absolute;
  left: 0; top: 0; height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.8s ease;
}

.analysis-bar.done .bar-fill::after { width: 100%; }

/* ==================== RESULT ==================== */
#result { justify-content: flex-start; align-items: stretch; padding: 0 0 48px; }
.result-content { width: 100%; animation: fadeInUp 0.5s ease; }

.result-hero { position: relative; margin-bottom: 28px; }

.result-badge {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 2;
  padding: 6px 14px;
  background: var(--accent);
  color: var(--bg);
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  border-radius: var(--r);
}

.result-image-full {
  width: 100%;
  height: 280px;
  overflow: hidden;
}
.result-image-full img { width: 100%; height: 100%; object-fit: cover; }

.result-info { padding: 0 24px; margin-bottom: 32px; }

#result h2, .result-content h2:first-of-type {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.result-origin {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text2);
  letter-spacing: 0.1em;
  margin-bottom: 16px;
}

.result-description {
  font-size: 0.9rem;
  color: var(--text2);
  line-height: 1.6;
  margin-bottom: 16px;
}

.result-flavors { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 0; }

.flavor-tag {
  padding: 4px 10px;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  border-radius: var(--r);
}

/* ==================== SECTIONS ==================== */
.section-label {
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--text2);
  letter-spacing: 0.2em;
  margin-bottom: 16px;
  text-align: left;
}

/* ==================== BLEND ==================== */
.blend-section {
  margin: 0 24px 32px;
  padding: 28px 24px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r);
}

.blend-name {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.02em;
  text-align: center;
  margin-bottom: 4px;
}

.blend-header { margin-bottom: 20px; }

.blend-chart-container { position: relative; width: 180px; height: 180px; margin: 0 auto 20px; overflow: hidden; }
#blendChart { display: block; }

.blend-center-label { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); text-align: center; }
.blend-pct-main { font-size: 1.8rem; font-weight: 800; color: var(--text); line-height: 1; }
.blend-pct-sub { font-family: var(--mono); font-size: 0.55rem; color: var(--text2); font-weight: 700; letter-spacing: 0.15em; margin-top: 2px; }

.blend-legend { display: flex; flex-direction: column; gap: 8px; }
.blend-legend-item { display: flex; align-items: center; gap: 10px; }
.blend-legend-dot { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.blend-legend-info { display: flex; justify-content: space-between; align-items: center; flex: 1; }
.blend-legend-name { font-size: 0.8rem; font-weight: 600; color: var(--text); }
.blend-legend-region { font-family: var(--mono); font-size: 0.6rem; color: var(--text2); letter-spacing: 0.06em; }
.blend-legend-pct { font-family: var(--mono); font-size: 0.85rem; font-weight: 700; color: var(--accent); }

.blend-serial {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.6rem;
  color: var(--text2);
  letter-spacing: 0.06em;
  text-align: center;
}

/* ==================== RADAR ==================== */
.radar-section { margin: 0 24px 32px; text-align: center; }
#radarChart { max-width: 260px; margin: 0 auto; display: block; }

/* ==================== RECIPE ==================== */
.recipe-section { margin: 0 24px 32px; }

.recipe-tabs { display: flex; gap: 4px; margin-bottom: 12px; overflow-x: auto; }

.recipe-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--bg2);
  cursor: pointer;
  transition: all 0.2s;
  opacity: 0.4;
  flex-shrink: 0;
}

.recipe-tab:hover { opacity: 0.6; }
.recipe-tab.active { opacity: 1; background: var(--accent); border-color: var(--accent); }

.tab-icon { width: 20px; height: 20px; color: var(--text2); }
.tab-icon svg { width: 100%; height: 100%; }
.recipe-tab.active .tab-icon { color: var(--bg); }

.tab-label { font-family: var(--mono); font-size: 0.5rem; font-weight: 700; color: var(--text2); letter-spacing: 0.06em; }
.recipe-tab.active .tab-label { color: var(--bg); }

.recipe-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px;
  animation: fadeInUp 0.25s ease;
}

.recipe-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.recipe-cell {}
.cell-label { font-family: var(--mono); font-size: 0.55rem; font-weight: 700; color: var(--text2); letter-spacing: 0.1em; margin-bottom: 4px; }
.cell-value { font-size: 1.1rem; font-weight: 700; color: var(--text); }

/* ==================== BARISTA QUOTE ==================== */
.barista-quote {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 0 24px 32px;
  padding: 20px;
  background: var(--bg2);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--r) var(--r) 0;
}
.barista-quote p { font-size: 0.88rem; color: var(--text2); line-height: 1.5; font-style: italic; }

/* ==================== DISCOUNT ==================== */
.discount-section {
  margin: 0 24px 28px;
  padding: 24px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  text-align: center;
}

.discount-text {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text2);
  margin-bottom: 12px;
  letter-spacing: 0.06em;
}

.discount-code {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  background: var(--bg);
  border: 2px dashed var(--accent);
  border-radius: var(--r);
  cursor: pointer;
  transition: all 0.2s;
}

.discount-code:hover { background: var(--accent-dim); }

.discount-code span:first-child {
  font-family: var(--mono);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.08em;
}

.copy-hint {
  font-family: var(--mono);
  font-size: 0.55rem;
  font-weight: 700;
  color: var(--text2);
  letter-spacing: 0.1em;
}

.discount-copied {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.1em;
  margin-top: 8px;
  opacity: 0;
  transition: opacity 0.3s;
  height: 16px;
}
.discount-copied.visible { opacity: 1; }

/* ==================== BOTTOM ACTIONS ==================== */
.result-content > .btn-primary {
  display: block;
  text-align: center;
  margin: 0 24px 12px;
}

.bottom-actions {
  display: flex;
  gap: 8px;
  padding: 0 24px;
  margin-bottom: 20px;
}

.share-btn, .restart-link {
  flex: 1;
  padding: 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text2);
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.share-btn:hover, .restart-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ==================== ANIMATIONS ==================== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes slideOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(-24px); }
}
@keyframes slideInReverse {
  from { opacity: 0; transform: translateX(-24px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-4px); }
}
@keyframes pulseRing {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.3); opacity: 0; }
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 380px) {
  h1 { font-size: 2rem; }
  .barista-avatar { width: 80px; height: 80px; }
  .question-num { font-size: 2rem; }
  .tile { padding: 16px 10px; min-height: 85px; }
  .result-image-full { height: 220px; }
}
