/* ===== Neon dark-mode theme ===== */
:root {
  --bg: #03040c;
  --neon: #6fe8ff;
  --neon-dim: rgba(111, 232, 255, 0.45);
  --neon-faint: rgba(111, 232, 255, 0.12);
  --danger: #ff6f9c;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* Every button in the app squishes down slightly on tap. */
button { transition: transform 0.1s ease; }
button.btn-press { transform: scale(0.92); }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--neon);
  font-family: -apple-system, "SF Pro Text", system-ui, sans-serif;
  /* Soft glow on every bit of text in the app, kid or app generated. */
  text-shadow: 0 0 6px var(--neon-dim), 0 0 14px var(--neon-faint);
  touch-action: manipulation;
  overscroll-behavior: none;
}

.view { display: none; padding: 20px 16px 40px; min-height: 100vh; }
.view.active { display: block; }

/* ---------- Home screen ---------- */
.app-title {
  text-align: center;
  font-size: 3rem;
  margin: 30px 0 4px;
  letter-spacing: 2px;
  text-shadow: 0 0 10px var(--neon), 0 0 26px var(--neon-dim), 0 0 46px var(--neon-faint);
}
.app-subtitle {
  text-align: center;
  opacity: 0.8;
  margin: 0 0 30px;
}
.theme-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  max-width: 520px;
  margin: 0 auto;
}
.theme-tile {
  background: rgba(111, 232, 255, 0.05);
  border: 2px solid var(--neon-dim);
  border-radius: 20px;
  color: var(--neon);
  font-size: 1.15rem;
  font-weight: 600;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 0 18px var(--neon-faint) inset;
  -webkit-touch-callout: none; /* stop iOS's own long-press popup from fighting our custom one */
  -webkit-user-select: none;
  user-select: none;
}
.theme-tile:active {
  background: rgba(111, 232, 255, 0.16);
  box-shadow: 0 0 24px var(--neon-dim), 0 0 24px var(--neon-faint) inset;
}
.theme-emoji { font-size: 2.6rem; }
.theme-tile-photo {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  object-fit: cover;
  border: 1px solid var(--neon-dim);
}
.new-list-tile {
  border-style: dashed;
  background: transparent;
  box-shadow: none;
  opacity: 0.85;
}
.deleted-lists-btn {
  display: block;
  margin: 24px auto 0;
}
.logout-btn {
  display: block;
  margin: 12px auto 0;
  opacity: 0.7;
}
.auth-error {
  text-align: center;
  color: var(--danger);
  text-shadow: 0 0 8px rgba(255, 111, 156, 0.6);
  font-size: 0.9rem;
  margin: 14px 0 18px;
}
.save-banner {
  position: fixed;
  left: 50%;
  bottom: 100px;
  transform: translateX(-50%);
  background: rgba(255, 111, 156, 0.15);
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 0.9rem;
  text-align: center;
  text-shadow: 0 0 8px rgba(255, 111, 156, 0.6);
  z-index: 60;
}

/* ---------- Shared top bar ---------- */
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.bar .icon-btn { white-space: nowrap; }
.bar-title {
  flex: 1;
  text-align: center;
  font-size: 1.4rem;
  margin: 0;
  background: none;
  border: none;
  font-family: inherit;
  color: inherit;
  text-shadow: inherit;
  min-height: 44px;
}
.icon-btn {
  background: transparent;
  border: 1px solid var(--neon-dim);
  color: var(--neon);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.95rem;
  min-height: 48px;
}
.badge {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--neon);
  color: #03040c;
  text-shadow: none;
  font-size: 0.8rem;
}

/* ---------- Item list ---------- */
.item-list { list-style: none; margin: 0; padding: 0; }
.item-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(111, 232, 255, 0.05);
  border: 1px solid var(--neon-faint);
  border-radius: 16px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
.item-row.dragging {
  opacity: 0.85;
  border-color: var(--neon);
  box-shadow: 0 0 20px var(--neon-dim);
  z-index: 5;
  position: relative;
}
.item-rank {
  font-size: 1.3rem;
  font-weight: 700;
  min-width: 34px;
  text-align: center;
}
.item-thumb {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--neon-dim);
  flex-shrink: 0;
}
.item-thumb.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  background: rgba(111, 232, 255, 0.08);
}
.item-info {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  text-align: left;
  padding: 0;
  font: inherit;
  color: inherit;
  min-height: 44px;
}
.item-name {
  font-size: 1.05rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item-stars { color: var(--neon); opacity: 0.9; font-size: 0.95rem; white-space: nowrap; }
.mini-star { position: relative; display: inline-block; width: 1.05em; }
.mini-star-empty { color: rgba(111, 232, 255, 0.35); }
.mini-star-fill {
  position: absolute;
  left: 0;
  top: 0;
  overflow: hidden;
  white-space: nowrap;
}
.drag-handle {
  font-size: 1.4rem;
  padding: 12px 10px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  touch-action: none; /* only the handle blocks scrolling, so the rest of the row still scrolls normally */
}
.delete-btn {
  background: transparent;
  border: 1px solid rgba(255, 111, 156, 0.5);
  color: var(--danger);
  border-radius: 12px;
  min-width: 48px;
  min-height: 48px;
  font-size: 1.2rem;
  text-shadow: 0 0 8px rgba(255, 111, 156, 0.6);
}

.empty-message { text-align: center; opacity: 0.6; margin-top: 60px; }
.hint-text { text-align: center; opacity: 0.7; font-size: 0.9rem; margin: -6px 0 18px; }

/* ---------- Floating add button ---------- */
.fab {
  position: fixed;
  right: 22px;
  bottom: 28px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--neon);
  color: #03040c;
  text-shadow: none;
  font-size: 2rem;
  border: none;
  box-shadow: 0 0 22px var(--neon-dim), 0 0 40px var(--neon-faint);
}
.fab:active { background: #a4f3ff; }

/* ---------- Recently Deleted row buttons ---------- */
.restore-btn, .forever-btn {
  border-radius: 12px;
  min-height: 48px;
  padding: 0 14px;
  font-size: 0.9rem;
  border: 1px solid var(--neon-dim);
  background: transparent;
  color: var(--neon);
}
.forever-btn {
  border-color: rgba(255, 111, 156, 0.5);
  color: var(--danger);
  text-shadow: 0 0 8px rgba(255, 111, 156, 0.6);
}
.deleted-actions { display: flex; flex-direction: column; gap: 8px; }

/* ---------- Modal (Add item) ---------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  align-items: flex-end;
  justify-content: center;
  z-index: 20;
}
.modal-overlay.active { display: flex; }
.modal {
  background: #05060f;
  border: 1px solid var(--neon-dim);
  border-radius: 22px 22px 0 0;
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 22px 20px 34px;
  box-shadow: 0 0 40px var(--neon-faint);
}
.modal-title { margin: 0 0 16px; text-align: center; }
.field-label { display: block; margin: 14px 0 6px; font-size: 0.9rem; opacity: 0.85; }
.text-input, .file-input {
  width: 100%;
  background: rgba(111, 232, 255, 0.06);
  border: 1px solid var(--neon-dim);
  border-radius: 12px;
  color: var(--neon);
  caret-color: var(--neon);
  padding: 14px;
  font-size: 1rem;
  text-shadow: 0 0 6px var(--neon-dim);
}
.text-input::placeholder { color: rgba(111, 232, 255, 0.4); }

.star-picker { display: flex; gap: 8px; }
.star {
  position: relative;
  background: transparent;
  border: none;
  font-size: 2.2rem;
  min-width: 48px;
  min-height: 48px;
  padding: 0;
}
.star-glyph {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  pointer-events: none;
}
.star-glyph-empty { color: rgba(111, 232, 255, 0.25); }
.star-glyph-fill {
  /* Same centered box as the empty star underneath it -- only how much of
     it is visible changes, via clip-path, so the two glyphs always line up
     exactly instead of drifting off-center as the fill amount changes. */
  color: var(--neon);
  text-shadow: 0 0 10px var(--neon), 0 0 18px var(--neon-dim);
  clip-path: inset(0 100% 0 0);
}

.lookup-btn {
  display: block;
  width: 100%;
  min-height: 48px;
  margin-top: 10px;
  border-radius: 12px;
  border: 1px solid var(--neon-dim);
  background: rgba(111, 232, 255, 0.07);
  color: var(--neon);
  font-size: 0.95rem;
  font-weight: 600;
}
.lookup-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  max-height: 260px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.lookup-result {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 60px;
  background: rgba(111, 232, 255, 0.05);
  border: 1px solid var(--neon-faint);
  border-radius: 12px;
  padding: 8px 10px;
  color: var(--neon);
  text-align: left;
  font-size: 1rem;
  font-family: inherit;
}
.lookup-result img, .lookup-thumb-placeholder {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--neon-dim);
  flex-shrink: 0;
}
.lookup-thumb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(111, 232, 255, 0.08);
  font-size: 1rem;
}
.lookup-result-text { min-width: 0; }
.lookup-result-title {
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lookup-result-subtitle {
  font-size: 0.8rem;
  opacity: 0.75;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.photo-preview {
  margin-top: 12px;
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  background: rgba(111, 232, 255, 0.05);
  border-radius: 14px;
  border: 1px solid var(--neon-dim);
}
/* !important here on purpose: .hidden is used all over the app as an
   on/off switch, so it needs to always win over any other styling a box
   has, even ones with more specific rules (like the two-class rule that
   was quietly beating .hidden and leaving an empty placeholder box behind
   an Auto Rank photo). */
.hidden { display: none !important; }

.modal-buttons { display: flex; gap: 12px; margin-top: 22px; }
.btn {
  flex: 1;
  min-height: 54px;
  border-radius: 14px;
  font-size: 1.05rem;
  font-weight: 600;
  border: 1px solid var(--neon-dim);
  background: transparent;
  color: var(--neon);
}
.btn-solid {
  background: var(--neon);
  color: #03040c;
  text-shadow: none;
  box-shadow: 0 0 20px var(--neon-dim);
}

/* ---------- Auto Rank (demo feature) ---------- */
.auto-rank-btn {
  display: block;
  width: 100%;
  min-height: 56px;
  margin-bottom: 16px;
  border-radius: 14px;
  border: 1px solid var(--neon-dim);
  background: rgba(111, 232, 255, 0.07);
  color: var(--neon);
  font-size: 1.05rem;
  font-weight: 600;
  box-shadow: 0 0 14px var(--neon-faint) inset;
}
.share-buttons { margin-top: 22px; }
.autorank-pair {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 30px;
}
.autorank-vs {
  font-weight: 700;
  font-size: 1.1rem;
  opacity: 0.8;
}
.autorank-card {
  flex: 1;
  min-height: 220px;
  background: rgba(111, 232, 255, 0.05);
  border: 2px solid var(--neon-dim);
  border-radius: 18px;
  color: var(--neon);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 16px 10px;
}
.autorank-card:active {
  background: rgba(111, 232, 255, 0.18);
  box-shadow: 0 0 22px var(--neon-dim);
}
.autorank-thumb {
  width: 84px;
  height: 84px;
  border-radius: 14px;
  object-fit: cover;
  border: 1px solid var(--neon-dim);
}
.autorank-thumb.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  background: rgba(111, 232, 255, 0.08);
}
.autorank-name {
  font-size: 1.05rem;
  font-weight: 600;
  text-align: center;
  word-break: break-word;
}

.delete-list-btn {
  display: block;
  width: 100%;
  min-height: 48px;
  margin-top: 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 111, 156, 0.5);
  background: transparent;
  color: var(--danger);
  font-size: 0.95rem;
  font-weight: 600;
  text-shadow: 0 0 8px rgba(255, 111, 156, 0.6);
}

/* ---------- Share image preview (fallback when the Share Sheet isn't available) ---------- */
.share-image-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 50;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
}
.share-image-overlay.active { display: flex; }
.share-image-overlay img {
  max-width: 100%;
  max-height: 72vh;
  border-radius: 14px;
  box-shadow: 0 0 24px var(--neon-faint);
}
.share-image-close {
  position: absolute;
  top: 20px;
  right: 20px;
}
