/* ============================================
   ROAST CARDS — Mobile-First PWA Styles
   ============================================ */

:root {
  --primary: #6C3CE1;
  --primary-light: #8B5CF6;
  --primary-dark: #5521C4;
  --accent: #FF6B35;
  --accent-light: #FF8F62;
  --bg: #0F0B1A;
  --bg-card: #1A1428;
  --bg-surface: #231C35;
  --text: #F5F0FF;
  --text-muted: #A89CC8;
  --success: #10B981;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 8px 32px rgba(108, 60, 225, 0.2);
  --shadow-lg: 0 16px 48px rgba(108, 60, 225, 0.3);
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Background gradient effect */
body::before {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 30% 20%, rgba(108, 60, 225, 0.15) 0%, transparent 50%),
              radial-gradient(circle at 70% 80%, rgba(255, 107, 53, 0.1) 0%, transparent 50%);
  z-index: -1;
  pointer-events: none;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px;
  padding-bottom: env(safe-area-inset-bottom, 16px);
}

/* ---- Header ---- */
.header {
  text-align: center;
  padding: 24px 0 16px;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.logo-icon {
  font-size: 2rem;
  animation: flame 1.5s ease-in-out infinite;
}

@keyframes flame {
  0%, 100% { transform: scale(1) rotate(0deg); }
  25% { transform: scale(1.1) rotate(-5deg); }
  75% { transform: scale(1.05) rotate(5deg); }
}

.logo h1 {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.tagline {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 6px;
  font-weight: 500;
}

/* ---- Card ---- */
.main {
  padding-bottom: 24px;
}

.card-container {
  perspective: 1200px;
  margin-bottom: 20px;
}

.roast-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid rgba(139, 92, 246, 0.2);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: var(--transition);
  position: relative;
}

.roast-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.roast-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.card-inner {
  padding: 12px 12px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-height: auto;
  position: relative;
}

.character-display {
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.character-display svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 4px 12px rgba(108, 60, 225, 0.3));
}

/* Card generation animation */
.roast-card.generating .character-display {
  animation: bounce-in 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

.roast-card.generating .speech-bubble {
  animation: slide-up 0.4s ease-out 0.2s both;
}

@keyframes bounce-in {
  0% { transform: scale(0.3) rotate(-10deg); opacity: 0; }
  60% { transform: scale(1.1) rotate(3deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); }
}

@keyframes slide-up {
  0% { transform: translateY(20px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

/* Speech Bubble */
.speech-bubble {
  background: var(--bg-surface);
  border: 1px solid rgba(139, 92, 246, 0.15);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  width: 100%;
  position: relative;
  text-align: center;
}

.speech-bubble::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 8px solid var(--bg-surface);
}

.roast-text {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text);
}

.card-watermark {
  position: absolute;
  bottom: 8px;
  right: 12px;
  font-size: 0.65rem;
  color: rgba(168, 156, 200, 0.3);
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* ---- Buttons ---- */
.actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0);
  transition: var(--transition);
}

.btn:active::after {
  background: rgba(255, 255, 255, 0.1);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  padding: 14px 28px;
  font-size: 1.1rem;
  box-shadow: 0 4px 14px rgba(108, 60, 225, 0.35);
  width: 100%;
  letter-spacing: 0.3px;
  animation: pulse-glow 2.5s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 4px 14px rgba(108, 60, 225, 0.3); }
  50% { box-shadow: 0 5px 20px rgba(108, 60, 225, 0.5); }
}

.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(108, 60, 225, 0.45);
  transform: translateY(-1px);
  animation: none;
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary .btn-icon {
  font-size: 1.3rem;
}

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

.btn-secondary {
  flex: 1;
  background: var(--bg-surface);
  color: var(--text);
  padding: 14px 20px;
  border: 1px solid rgba(139, 92, 246, 0.2);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--primary-light);
  background: rgba(139, 92, 246, 0.1);
}

.btn-secondary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-small {
  padding: 8px 16px;
  font-size: 0.85rem;
  background: var(--primary);
  color: white;
  border-radius: 8px;
}

.btn-dismiss {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
}

/* ---- Brand Tag ---- */
.brand-tag {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent);
  background: rgba(255, 107, 53, 0.12);
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.3px;
}

/* ---- Credit Badge ---- */
.credit-badge {
  display: inline-block;
  margin-top: 10px;
  padding: 5px 14px;
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: 20px;
  background: rgba(16, 185, 129, 0.15);
  color: #10B981;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.credit-badge.low {
  background: rgba(251, 191, 36, 0.15);
  color: #FBBF24;
  border-color: rgba(251, 191, 36, 0.25);
}

.credit-badge.depleted {
  background: rgba(239, 68, 68, 0.15);
  color: #EF4444;
  border-color: rgba(239, 68, 68, 0.25);
}

/* ---- Stats Bar ---- */
.stats-bar {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 16px;
}

.stat-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface);
  border: 1px solid rgba(139, 92, 246, 0.1);
  border-radius: 20px;
  padding: 5px 14px;
}

.stat-chip-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-chip-value {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--primary-light);
}

/* ---- Character Picker ---- */
.character-picker {
  margin-bottom: 16px;
  overflow: visible;
}

.character-picker h2 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--text-muted);
  text-align: center;
}

.character-grid {
  overflow: hidden;
  padding: 4px 0 10px;
  position: relative;
}

.char-scroll-track {
  display: flex;
  gap: 10px;
  width: max-content;
  will-change: transform;
}

.char-thumb {
  flex: 0 0 80px;
  width: 80px;
  height: 80px;
  background: var(--bg-surface);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  padding: 6px;
  position: relative;
}

.char-thumb:hover {
  border-color: rgba(139, 92, 246, 0.3);
  background: rgba(139, 92, 246, 0.1);
  transform: scale(1.05);
}

.char-thumb.active {
  border-color: var(--primary-light);
  background: rgba(139, 92, 246, 0.15);
  box-shadow: 0 0 20px rgba(108, 60, 225, 0.4), inset 0 0 8px rgba(139, 92, 246, 0.1);
  transform: scale(1.1);
}

.char-thumb svg {
  width: 100%;
  height: 100%;
}

.char-thumb.locked {
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.char-thumb.locked svg {
  filter: blur(3px) grayscale(0.8);
  opacity: 0.4;
}

.lock-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 11, 26, 0.5);
  border-radius: var(--radius-sm);
  font-size: 1.3rem;
}

.char-thumb.locked:hover {
  border-color: var(--accent);
  background: rgba(255, 107, 53, 0.08);
  transform: scale(1.05);
}

.char-thumb.pickable {
  border: 2px solid var(--success);
  animation: pick-pulse 1.5s ease-in-out infinite;
  background: rgba(16, 185, 129, 0.06);
}

.char-thumb.pickable svg {
  opacity: 0.85;
}

.char-thumb.pickable:hover {
  border-color: var(--success);
  background: rgba(16, 185, 129, 0.1);
  transform: scale(1.08);
}

@keyframes pick-pulse {
  0%, 100% { border-color: rgba(16, 185, 129, 0.4); }
  50% { border-color: rgba(16, 185, 129, 1); }
}

.char-thumb.picked {
  border-color: var(--success);
  background: rgba(16, 185, 129, 0.1);
}

/* ---- Upgrade Banner ---- */
.upgrade-banner {
  margin-bottom: 20px;
  margin-top: 0;
  clear: both;
  position: relative;
  z-index: 1;
}

.upgrade-content {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, rgba(108, 60, 225, 0.15), rgba(255, 107, 53, 0.1));
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.upgrade-icon {
  font-size: 1.5rem;
}

.upgrade-content div {
  flex: 1;
}

.upgrade-content strong {
  font-size: 0.9rem;
  display: block;
}

.upgrade-content p {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0;
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent), #E8590C);
  color: white;
  padding: 10px 18px;
  font-size: 0.85rem;
  border-radius: 10px;
  white-space: nowrap;
  box-shadow: 0 2px 10px rgba(255, 107, 53, 0.3);
}

.btn-accent:hover {
  box-shadow: 0 4px 16px rgba(255, 107, 53, 0.4);
  transform: translateY(-1px);
}

/* ---- Install Banner ---- */
.install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border-top: 1px solid rgba(139, 92, 246, 0.2);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 100;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.install-banner p {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 600;
}

/* ---- Footer ---- */
.footer {
  padding: 24px 0 32px;
  border-top: 1px solid rgba(139, 92, 246, 0.1);
}

.safety-notice {
  text-align: center;
}

.safety-notice h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--primary-light);
}

.safety-notice p {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 12px;
}

.footer-links {
  font-size: 0.75rem !important;
}

.footer-links a {
  color: var(--primary-light);
  text-decoration: none;
}

.footer-links a:hover {
  text-decoration: underline;
}

/* ---- Modal ---- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 11, 26, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
}

.modal-content {
  background: var(--bg-surface);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: var(--radius);
  padding: 28px 24px;
  max-width: 400px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}

.modal-content h2 {
  font-size: 1.3rem;
  margin-bottom: 12px;
}

.modal-content h3 {
  font-size: 1rem;
  margin: 16px 0 8px;
  color: var(--primary-light);
}

.modal-content p {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 8px;
}

.modal-content ul {
  list-style: none;
  padding: 0;
}

.modal-content li {
  padding: 4px 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.hidden {
  display: none !important;
}

/* ---- Toast Notification ---- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--success);
  color: white;
  padding: 12px 24px;
  border-radius: 50px;
  font-size: 0.9rem;
  font-weight: 600;
  z-index: 300;
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ---- Responsive ---- */
@media (min-width: 480px) {
  #app {
    padding: 0 24px;
  }
}

@media (min-width: 640px) {
  #app {
    max-width: 520px;
  }

  .character-display {
    width: 200px;
    height: 200px;
  }

  .card-inner {
    min-height: auto;
    padding: 16px 16px 12px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Dark mode is default, but handle light mode preference if needed */
@media (prefers-color-scheme: light) {
  /* Keep dark — it's the brand identity */
}

/* ---- Paywall Modal ---- */
.paywall-content {
  text-align: center;
  padding: 32px 24px;
}

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

.paywall-emoji {
  font-size: 3rem;
  display: block;
  margin-bottom: 8px;
  animation: flame 1.5s ease-in-out infinite;
}

.paywall-header h2 {
  font-size: 1.5rem;
  margin-bottom: 6px;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.paywall-header p {
  text-align: center;
}

.paywall-offer {
  margin-bottom: 20px;
}

.offer-card {
  background: linear-gradient(135deg, rgba(108, 60, 225, 0.2), rgba(255, 107, 53, 0.1));
  border: 2px solid var(--primary-light);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
}

.offer-badge {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: white;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 3px 12px;
  border-radius: 20px;
  letter-spacing: 1px;
}

.offer-count {
  font-size: 3rem;
  font-weight: 900;
  color: var(--text);
  line-height: 1;
}

.offer-label {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.offer-price {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  margin-bottom: 4px;
}

.price-amount {
  font-size: 2rem;
  font-weight: 900;
  color: var(--accent);
}

.price-currency {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
}

.offer-per {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.btn-buy {
  margin-bottom: 12px;
  font-size: 1.05rem;
}

.paywall-secure {
  font-size: 0.78rem !important;
  color: var(--text-muted) !important;
  text-align: center;
}

.paywall-note {
  font-size: 0.72rem !important;
  color: rgba(168, 156, 200, 0.5) !important;
  text-align: center;
}

/* ---- Stats Modal (Admin) ---- */
.stats-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 12px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(139, 92, 246, 0.05);
}

.stat-row:nth-child(odd) {
  background: rgba(139, 92, 246, 0.1);
}

.stat-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

.stat-value {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
}

/* ---- Install Icon ---- */
.install-icon {
  font-size: 1.3rem;
}
