:root {
  color-scheme: light dark;
  --bg: #f5f6f8;
  --card-bg: #ffffff;
  --text: #1a1c20;
  --muted: #6b7280;
  --accent: #2563eb;
  --checked: #16a34a;
  --border: #e2e5ea;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181d;
    --card-bg: #22252b;
    --text: #eceef1;
    --muted: #9aa1ac;
    --accent: #5b8def;
    --checked: #34c25f;
    --border: #33363d;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 16px 20px 8px;
  flex-wrap: wrap;
  gap: 8px;
}

.topbar h1 {
  font-size: 1.3rem;
  margin: 0;
}

.stats {
  font-size: 0.9rem;
  color: var(--muted);
}

#countCheckedIn { color: var(--checked); font-weight: 600; }

.controls {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  padding: 8px 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#searchBox {
  width: 100%;
  padding: 14px 16px;
  font-size: 1.1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card-bg);
  color: var(--text);
}

#searchBox:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filterBtn {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
}

.filterBtn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  padding: 0 20px 40px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  position: relative;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0,0,0,0.12);
}

.card.checked {
  outline: 3px solid var(--checked);
}

.card .photo-wrap {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--border);
  overflow: hidden;
}

.card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card .info {
  padding: 8px 10px 10px;
}

.card .name {
  font-weight: 600;
  font-size: 0.88rem;
  line-height: 1.2;
}

.card .country {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 2px;
}

.badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--checked);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 999px;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 20px;
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.lightbox[hidden] {
  display: none;
}

.lightbox-inner {
  background: var(--card-bg);
  border-radius: 14px;
  overflow: hidden;
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.lightbox-inner img {
  width: 100%;
  max-height: 55vh;
  object-fit: contain;
  background: #000;
}

.lightbox-info {
  padding: 16px 20px 20px;
  text-align: center;
}

.lightbox-name {
  font-size: 1.2rem;
  font-weight: 700;
}

.lightbox-country {
  color: var(--muted);
  margin-top: 4px;
  margin-bottom: 16px;
}

.checkin-btn {
  padding: 12px 20px;
  border-radius: 10px;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  margin-bottom: 10px;
  background: var(--accent);
  color: #fff;
}

.checkin-btn.is-checked {
  background: var(--checked);
}

.close-btn {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
