:root {
  --bg: #0f1220;
  --bg-soft: #161b30;
  --card: #1b2140;
  --border: #2a3158;
  --text: #f3f4fb;
  --text-muted: #a4a9c9;
  --accent: #ff5470;
  --accent-2: #7c5cff;
  --success: #38d996;
  --radius: 16px;
  --max-width: 720px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Arial, sans-serif;
  background: linear-gradient(180deg, var(--bg) 0%, #0a0c18 100%);
  color: var(--text);
  min-height: 100vh;
}

/* Garante que qualquer elemento com o atributo "hidden" fique realmente
   escondido, mesmo quando sua própria classe (.grid, .btn, .lightbox, etc.)
   define um "display" fixo que, do contrário, sobrescreveria isso. */
[hidden] {
  display: none !important;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(15, 18, 32, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 14px 18px;
  display: flex;
  align-items: center;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
  height: 26px;
  width: auto;
  display: block;
}
.brand-text { display: flex; flex-direction: column; justify-content: center; line-height: 1.1; }
.brand-text small { color: var(--text-muted); font-size: 11px; }

main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 20px 18px 60px;
}

.hero { text-align: center; padding: 18px 0 8px; }
.hero h1 { font-size: 24px; margin: 0 0 8px; }
.hero p { color: var(--text-muted); margin: 0 auto; max-width: 480px; font-size: 15px; }

.day-tabs {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 18px 0;
}
.day-tab {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}
.day-tab.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  font-weight: 600;
}

.selfie-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  text-align: center;
  margin-bottom: 20px;
}
.selfie-preview {
  width: 96px; height: 96px;
  border-radius: 50%;
  background: var(--bg-soft);
  border: 2px dashed var(--border);
  margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  overflow: hidden;
}
.selfie-preview img { width: 100%; height: 100%; object-fit: cover; }

.btn {
  display: inline-block;
  border: none;
  border-radius: 999px;
  padding: 12px 22px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: opacity .15s ease, transform .1s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-accent {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
}
.btn-accent:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn-small { padding: 8px 14px; font-size: 13px; }
.btn-link {
  background: none;
  color: var(--text-muted);
  text-decoration: underline;
  padding: 6px;
  font-size: 13px;
}

.hint { color: var(--text-muted); font-size: 12px; margin: 10px 0 0; }

.consent {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  text-align: left;
  margin: 20px 0;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.4;
}
.consent input { margin-top: 3px; }

.status {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 14px;
}
.status.error { color: var(--accent); }
.spinner {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
  margin: 0 auto 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.results-header h2 { font-size: 17px; margin: 0; }
.results-toolbar { display: flex; gap: 8px; }

.fallback-note {
  background: rgba(124, 92, 255, 0.15);
  border: 1px solid var(--accent-2);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 14px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}
.grid-item {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-soft);
  cursor: pointer;
}
.grid-item img {
  width: 100%; height: 100%; object-fit: cover;
  display: block;
}
.grid-item .check {
  position: absolute;
  top: 6px; right: 6px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(15,18,32,0.7);
  border: 2px solid white;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
}
.grid-item.selected .check {
  background: var(--success);
  border-color: var(--success);
}
.grid-item .score-badge {
  position: absolute;
  bottom: 4px; left: 4px;
  background: rgba(15,18,32,0.75);
  color: var(--text);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 999px;
}

.browse { margin-top: 40px; text-align: center; }
.browse .grid { text-align: left; margin-top: 16px; }
.browse #browse-more { margin-top: 14px; }

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(5,6,12,0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.lightbox img {
  max-width: 100%;
  max-height: 75vh;
  border-radius: 10px;
  object-fit: contain;
}
.lightbox-close {
  position: absolute;
  top: 16px; right: 16px;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.3);
  color: white;
  font-size: 26px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
}
.lightbox-close:hover { background: rgba(255,255,255,0.22); }
.lightbox-error {
  color: var(--text-muted);
  text-align: center;
  max-width: 320px;
  padding: 20px;
}
.lightbox-download { margin-top: 18px; }

footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  padding: 20px;
}

@media (min-width: 560px) {
  .grid { grid-template-columns: repeat(4, 1fr); }
}
