/* ── Reset & Base ── */
* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

body {
  font-family: "Poppins", sans-serif;
  background: #0a0a0f;
  min-height: 100vh;
  overflow-x: hidden;
}

.hidden {
  display: none !important;
}

/* ── Authentication Gate ── */
.auth-shell {
  position: relative;
  z-index: 1;
  width: min(92%, 460px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 2rem 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-card {
  width: 100%;
  padding: 2.2rem 1.5rem 1.6rem;
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(224, 26, 56, 0.08), transparent 30%),
    rgba(11, 14, 23, 0.92);
  border: 1px solid rgba(224, 26, 56, 0.16);
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.7),
    0 0 0 1px rgba(224, 26, 56, 0.08);
  backdrop-filter: blur(18px);
  animation: cardReveal 0.45s ease both;
}

.auth-eyebrow {
  margin-top: 0.7rem;
  color: #e01a38;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.auth-title {
  margin-top: 0.5rem;
  color: #fff;
  font-family: "Bebas Neue", sans-serif;
  font-size: 2.8rem;
  letter-spacing: 2px;
  line-height: 0.95;
}

.auth-subtitle {
  margin-top: 0.85rem;
  color: #a5b4c8;
  font-size: 0.88rem;
  line-height: 1.6;
}

.auth-mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 1.6rem 0 1.2rem;
  padding: 6px;
  border-radius: 20px;
  background: rgba(17, 20, 31, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.auth-mode-button {
  border: none;
  border-radius: 14px;
  background: transparent;
  color: #7d8598;
  padding: 0.85rem 1rem;
  font-family: "Poppins", sans-serif;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.25s, color 0.25s, transform 0.2s;
}

.auth-mode-button:hover {
  color: #fff;
}

.auth-mode-button.is-active {
  background: linear-gradient(135deg, #e01a38, #ff4d63);
  color: #fff;
  box-shadow: 0 12px 28px rgba(224, 26, 56, 0.35);
}

.auth-mode-button:disabled {
  opacity: 0.6;
  cursor: wait;
  transform: none;
}

.auth-form,
.auth-field {
  display: flex;
  flex-direction: column;
}

.auth-label {
  color: #cbd5e1;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.8px;
  margin-bottom: 0.42rem;
}

.auth-input {
  width: 100%;
  margin-bottom: 0.8rem;
  padding: 0.9rem 1rem;
  border-radius: 14px;
  border: 1.5px solid #2a2a4a;
  background: rgba(11, 14, 23, 0.95);
  color: #fff;
  font-family: "Poppins", sans-serif;
  font-size: 0.92rem;
  transition: border-color 0.25s, box-shadow 0.25s, transform 0.2s;
}

.auth-input::placeholder {
  color: #556070;
}

.auth-input:focus {
  outline: none;
  border-color: #e01a38;
  box-shadow: 0 0 0 3px rgba(224, 26, 56, 0.16);
  transform: translateY(-1px);
}

.auth-input:disabled {
  opacity: 0.7;
  cursor: wait;
}

.auth-submit-button {
  border: none;
  border-radius: 16px;
  padding: 0.95rem 1.15rem;
  background: linear-gradient(135deg, #e01a38, #ff3b55);
  color: #fff;
  font-family: "Poppins", sans-serif;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 16px 32px rgba(224, 26, 56, 0.28);
  transition: transform 0.2s, box-shadow 0.25s, filter 0.25s;
}

.auth-submit-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 34px rgba(224, 26, 56, 0.4);
  filter: brightness(1.04);
}

.auth-submit-button:disabled {
  opacity: 0.7;
  cursor: wait;
  transform: none;
  box-shadow: none;
}

.auth-feedback {
  min-height: 1.5rem;
  margin-top: 1rem;
  font-size: 0.82rem;
  line-height: 1.55;
}

.auth-feedback.muted {
  color: #94a3b8;
}

.auth-feedback.error {
  color: #fda4af;
}

.auth-feedback.success {
  color: #86efac;
}

.firebase-setup-note {
  margin-top: 1.35rem;
  padding: 1rem 1rem 1rem 1.1rem;
  border-radius: 18px;
  background: rgba(224, 26, 56, 0.08);
  border: 1px solid rgba(224, 26, 56, 0.16);
}

.firebase-setup-note h2 {
  color: #fff;
  font-size: 0.98rem;
  margin-bottom: 0.55rem;
}

.firebase-setup-note p {
  color: #cbd5e1;
  font-size: 0.82rem;
  line-height: 1.55;
}

.firebase-setup-note ol {
  margin: 0.75rem 0 0 1.1rem;
  color: #f8fafc;
  font-size: 0.8rem;
  line-height: 1.7;
}

.firebase-setup-note code {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border-radius: 6px;
  padding: 0.12rem 0.35rem;
}

/* ── Animated Background Particles ── */
.bg-particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.bg-particles span {
  position: absolute;
  display: block;
  border-radius: 50%;
  background: radial-gradient(circle, #e01a38 0%, transparent 70%);
  animation: float linear infinite;
  opacity: 0;
}
.bg-particles span:nth-child(1)  { width:60px;  height:60px;  left:10%; animation-duration:18s; animation-delay:0s;   top:100%; }
.bg-particles span:nth-child(2)  { width:30px;  height:30px;  left:25%; animation-duration:22s; animation-delay:3s;   top:100%; }
.bg-particles span:nth-child(3)  { width:80px;  height:80px;  left:40%; animation-duration:16s; animation-delay:1s;   top:100%; }
.bg-particles span:nth-child(4)  { width:20px;  height:20px;  left:55%; animation-duration:20s; animation-delay:5s;   top:100%; }
.bg-particles span:nth-child(5)  { width:50px;  height:50px;  left:65%; animation-duration:17s; animation-delay:2s;   top:100%; }
.bg-particles span:nth-child(6)  { width:40px;  height:40px;  left:75%; animation-duration:24s; animation-delay:4s;   top:100%; }
.bg-particles span:nth-child(7)  { width:25px;  height:25px;  left:85%; animation-duration:19s; animation-delay:6s;   top:100%; }
.bg-particles span:nth-child(8)  { width:70px;  height:70px;  left:5%;  animation-duration:21s; animation-delay:7s;   top:100%; }

@keyframes float {
  0%   { transform: translateY(0) rotate(0deg);   opacity: 0; }
  10%  { opacity: 0.15; }
  90%  { opacity: 0.08; }
  100% { transform: translateY(-110vh) rotate(720deg); opacity: 0; }
}

/* ── Main Container ── */
.container {
  position: relative;
  z-index: 1;
  width: 92%;
  max-width: 480px;
  margin: 0 auto;
  padding: 0 0 3em 0;
}

.session-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 1.6rem;
  margin-bottom: 0.25rem;
  animation: slideDown 0.45s ease both;
}

.session-copy {
  color: #94a3b8;
  font-size: 0.79rem;
  line-height: 1.5;
}

.session-copy span {
  color: #fff;
  font-weight: 600;
  word-break: break-all;
}

.session-button {
  border: 1px solid rgba(224, 26, 56, 0.28);
  border-radius: 999px;
  padding: 0.78rem 1.15rem;
  background: rgba(224, 26, 56, 0.12);
  color: #fff;
  font-family: "Poppins", sans-serif;
  font-size: 0.77rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.25s, transform 0.2s, box-shadow 0.25s;
}

.session-button:hover {
  background: #e01a38;
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(224, 26, 56, 0.28);
}

.session-button:active {
  transform: translateY(0);
}

/* ── Header ── */
.header {
  text-align: center;
  padding: 2.5em 0 1.8em 0;
  animation: slideDown 0.6s ease both;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-30px); }
  to   { opacity: 1; transform: translateY(0); }
}

.marvel-badge {
  display: inline-block;
  background: #e01a38;
  color: #fff;
  font-family: "Bebas Neue", sans-serif;
  font-size: 1.5em;
  letter-spacing: 4px;
  padding: 4px 18px;
  border-radius: 4px;
  margin-bottom: 0.4em;
  box-shadow: 0 0 20px rgba(224, 26, 56, 0.7), 0 0 40px rgba(224, 26, 56, 0.3);
  animation: pulse-glow 2.5s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 20px rgba(224,26,56,0.7), 0 0 40px rgba(224,26,56,0.3); }
  50%       { box-shadow: 0 0 35px rgba(224,26,56,1),   0 0 70px rgba(224,26,56,0.5); }
}

.app-title {
  font-family: "Bebas Neue", sans-serif;
  font-size: 3em;
  letter-spacing: 6px;
  color: #ffffff;
  line-height: 1;
  text-shadow: 0 0 30px rgba(224, 26, 56, 0.5);
}

.app-subtitle {
  color: #888;
  font-size: 0.78em;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-top: 0.4em;
}

/* ── Search Wrapper ── */
.search-wrapper {
  position: relative;
  z-index: 100;
  animation: slideDown 0.6s 0.15s ease both;
}

.input-container {
  display: flex;
  align-items: center;
  background: #1a1a2e;
  border: 1.5px solid #2a2a4a;
  border-radius: 50px;
  padding: 6px 6px 6px 18px;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.input-container:focus-within {
  border-color: #e01a38;
  box-shadow: 0 0 0 3px rgba(224, 26, 56, 0.18), 0 0 20px rgba(224, 26, 56, 0.12);
}

.search-icon {
  color: #555;
  font-size: 1.1em;
  margin-right: 10px;
  flex-shrink: 0;
}

.input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #ffffff;
  font-family: "Poppins", sans-serif;
  font-size: 0.95em;
  min-width: 0;
}

.input::placeholder { color: #444; }

.button {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #e01a38;
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 0.75em 1.4em;
  font-family: "Poppins", sans-serif;
  font-size: 0.88em;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.25s, transform 0.2s, box-shadow 0.25s;
  box-shadow: 0 4px 15px rgba(224, 26, 56, 0.4);
}

.button:hover {
  background: #ff2244;
  transform: scale(1.05);
  box-shadow: 0 6px 25px rgba(224, 26, 56, 0.65);
}

.button:active { transform: scale(0.97); }

.btn-arrow {
  font-size: 1.1em;
  transition: transform 0.2s;
}

.button:hover .btn-arrow { transform: translateX(3px); }

/* ── Autocomplete Dropdown ── */
.list {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: #12121e;
  border: 1.5px solid #2a2a4a;
  border-radius: 16px;
  overflow-y: auto;
  max-height: 300px;
  z-index: 999;
  box-shadow: 0 16px 50px rgba(0,0,0,0.75);
  animation: dropdownOpen 0.25s ease both;
}

@keyframes dropdownOpen {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Scrollbar */
.list::-webkit-scrollbar { width: 4px; }
.list::-webkit-scrollbar-track { background: transparent; }
.list::-webkit-scrollbar-thumb { background: #e01a38; border-radius: 4px; }

/* Alphabet section header */
.alpha-header {
  padding: 0.4em 1.2em 0.2em;
  font-size: 0.7em;
  font-weight: 700;
  letter-spacing: 2px;
  color: #e01a38;
  text-transform: uppercase;
  background: rgba(224, 26, 56, 0.06);
  border-top: 1px solid rgba(224, 26, 56, 0.12);
  position: sticky;
  top: 0;
  z-index: 1;
}

.alpha-header:first-child { border-top: none; }

.autocomplete-items {
  padding: 0.65em 1.2em 0.65em 1.5em;
  color: #bbb;
  font-size: 0.88em;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, padding-left 0.18s;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

.autocomplete-items:last-child { border-bottom: none; }

.autocomplete-items:hover {
  background: rgba(224, 26, 56, 0.13);
  color: #fff;
  padding-left: 1.9em;
}

.autocomplete-items b { color: #e01a38; font-weight: 700; }

.dropdown-footer {
  padding: 0.6em 1.2em;
  font-size: 0.72em;
  color: #555;
  text-align: center;
  letter-spacing: 0.5px;
  border-top: 1px solid rgba(255,255,255,0.04);
  font-style: italic;
}

/* ── Display Container ── */
.display-container {
  margin-top: 1.6em;
  position: relative;
  z-index: 1;
}

/* ── Character Card ── */
.card-container {
  display: flex;
  flex-direction: column;
  background: #13131f;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid #2a2a4a;
  box-shadow: 0 20px 60px rgba(0,0,0,0.7), 0 0 0 1px rgba(224,26,56,0.08);
  animation: cardReveal 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  transform-origin: top center;
  transition: box-shadow 0.3s, border-color 0.3s;
}

.card-container:hover {
  border-color: rgba(224,26,56,0.4);
  box-shadow: 0 24px 70px rgba(0,0,0,0.85), 0 0 0 1px rgba(224,26,56,0.2);
}

@keyframes cardReveal {
  from { opacity: 0; transform: scale(0.9) translateY(18px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Image section ── */
.card-image-wrapper {
  position: relative;
  width: 100%;
  height: 359px;
  overflow: hidden;
  background: radial-gradient(ellipse at center, #1a1a2e 0%, #0d0d1a 100%);
  flex-shrink: 0;
}

.card-image-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center top;
  display: block;
  transition: transform 0.55s ease;
}

.card-container:hover .card-image-wrapper img {
  transform: scale(1.05);
}

/* Gradient fade at bottom of image into card body */
.card-image-wrapper::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 55%;
  background: linear-gradient(to top, #13131f 0%, transparent 100%);
  pointer-events: none;
}

/* Name + badge overlaid on image gradient */
.card-name-overlay {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 0 1.2em 0.8em;
  z-index: 1;
}

.character-name {
  font-family: "Bebas Neue", sans-serif;
  font-size: 2em;
  letter-spacing: 3px;
  color: #ffffff;
  line-height: 1.05;
  text-shadow: 0 2px 12px rgba(0,0,0,0.8), 0 0 30px rgba(224,26,56,0.4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.alignment-badge {
  display: inline-block;
  font-size: 0.62em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 2px 10px;
  border-radius: 20px;
  margin-top: 0.3em;
}

.alignment-good    { background: rgba(74, 222, 128, 0.18); color: #4ade80; border: 1px solid rgba(74,222,128,0.35); }
.alignment-bad     { background: rgba(248, 113, 113, 0.18); color: #f87171; border: 1px solid rgba(248,113,113,0.35); }
.alignment-neutral { background: rgba(251, 191, 36, 0.18); color: #fbbf24; border: 1px solid rgba(251,191,36,0.35); }

.card-image-id {
  position: absolute;
  top: 12px;
  right: 14px;
  background: rgba(224, 26, 56, 0.9);
  color: #fff;
  font-size: 0.65em;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 1px;
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 14px rgba(224,26,56,0.5);
  z-index: 1;
  white-space: nowrap;
}

/* ── Online image search spinner ── */
.img-searching {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6em;
  background: rgba(10,10,20,0.55);
  z-index: 2;
  pointer-events: none;
}

.img-searching p {
  font-size: 0.7em;
  color: #aaa;
  letter-spacing: 1px;
  margin: 0;
}

.img-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(224,26,56,0.2);
  border-top-color: #e01a38;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ── Card body (info + download) ── */
.card-body {
  padding: 0.6em 1.2em 1.1em;
}

/* 2-column info grid */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid rgba(224,26,56,0.2);
  margin-bottom: 0.85em;
}

.info-cell {
  display: flex;
  flex-direction: column;
  padding: 0.5em 0.4em;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  animation: fadeInRow 0.4s ease both;
}

.info-cell:nth-child(odd)  { border-right: 1px solid rgba(255,255,255,0.04); padding-right: 0.8em; }
.info-cell:nth-child(even) { padding-left: 0.8em; }
.info-cell.full            { grid-column: 1 / -1; border-right: none; }
.info-cell:last-child      { border-bottom: none; }

.info-cell:nth-child(1) { animation-delay: 0.05s; }
.info-cell:nth-child(2) { animation-delay: 0.10s; }
.info-cell:nth-child(3) { animation-delay: 0.15s; }
.info-cell:nth-child(4) { animation-delay: 0.20s; }
.info-cell:nth-child(5) { animation-delay: 0.25s; }

@keyframes fadeInRow {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.info-label {
  font-size: 0.62em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #e01a38;
  margin-bottom: 0.2em;
}

.info-value {
  font-size: 0.8em;
  color: #ddd;
  word-break: break-word;
  line-height: 1.3;
}

/* ── Download Button ── */
.download-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  background: rgba(224, 26, 56, 0.1);
  color: #e01a38;
  border: 1px solid rgba(224, 26, 56, 0.3);
  border-radius: 12px;
  padding: 9px 0;
  font-family: "Poppins", sans-serif;
  font-size: 0.78em;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.25s, color 0.25s, border-color 0.25s, transform 0.2s, box-shadow 0.25s;
  letter-spacing: 0.5px;
}

.download-btn:hover {
  background: #e01a38;
  color: #fff;
  border-color: #e01a38;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(224, 26, 56, 0.5);
}

.download-btn:active { transform: translateY(0) scale(0.97); }

.download-btn svg { flex-shrink: 0; transition: transform 0.25s; }
.download-btn:hover svg { transform: translateY(2px); }

.download-btn:disabled {
  opacity: 0.65;
  cursor: default;
  transform: none;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ── Loading shimmer ── */
.loading-card {
  display: flex;
  flex-direction: column;
  background: #13131f;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid #2a2a4a;
  animation: cardReveal 0.3s ease both;
}

.shimmer-img {
  width: 100%;
  height: 359px;
  flex-shrink: 0;
  background: linear-gradient(90deg, #1a1a2e 25%, #22223a 50%, #1a1a2e 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}

.shimmer-lines {
  padding: 0.8em 1.2em 1em;
  display: flex;
  flex-direction: column;
  gap: 0.55em;
}

.shimmer-line {
  height: 12px;
  border-radius: 8px;
  background: linear-gradient(90deg, #1a1a2e 25%, #22223a 50%, #1a1a2e 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}

.shimmer-line.short { width: 40%; }
.shimmer-line.medium { width: 65%; }

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Not found ── */
.not-found {
  text-align: center;
  color: #555;
  padding: 2em;
  font-size: 0.9em;
  animation: cardReveal 0.4s ease both;
}

.not-found span {
  display: block;
  font-size: 2.5em;
  margin-bottom: 0.3em;
}

/* ── Copyright Footer ── */
.copyright {
  text-align: center;
  padding: 2em 0 1em;
  animation: slideDown 0.6s 0.3s ease both;
}

.copyright-divider {
  height: 1px;
  background: linear-gradient(to right, transparent, #e01a38, transparent);
  margin-bottom: 1.4em;
  opacity: 0.35;
}

.copyright-name {
  font-family: "Bebas Neue", sans-serif;
  font-size: 1.1em;
  letter-spacing: 2px;
  color: #e01a38;
  margin-bottom: 0.4em;
}

.copyright-detail {
  font-size: 0.75em;
  color: #666;
  margin-bottom: 0.2em;
  letter-spacing: 0.5px;
}

.copyright-detail a {
  color: #666;
  text-decoration: none;
  transition: color 0.2s;
}

.copyright-detail a:hover {
  color: #e01a38;
}

.copyright-year {
  font-size: 0.7em;
  color: #444;
  margin-top: 0.5em;
  letter-spacing: 1px;
}

@media (max-width: 520px) {
  .auth-shell {
    width: 92%;
    padding: 1.4rem 0;
  }

  .auth-card {
    padding: 1.8rem 1.05rem 1.25rem;
    border-radius: 22px;
  }

  .auth-title {
    font-size: 2.25rem;
  }

  .auth-mode-toggle {
    grid-template-columns: 1fr;
  }

  .session-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .session-button {
    width: 100%;
  }
}
