@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
  --bg: #0a0a0a;
  --bg-card: #141414;
  --bg-card-hover: #1a1a1a;
  --bg-input: #1e1e1e;
  --text: #f0f0f0;
  --text-dim: #888;
  --text-muted: #555;
  --accent: #22c55e;
  --accent-dim: #16a34a;
  --danger: #ef4444;
  --warning: #f59e0b;
  --blue: #3b82f6;
  --purple: #8b5cf6;
  --border: #2a2a2a;
  --radius: 12px;
  --radius-sm: 8px;
  --sat: 40px;
  --sab: 20px;
}

@supports (padding-top: constant(safe-area-inset-top)) {
  :root {
    --sat: constant(safe-area-inset-top);
    --sab: constant(safe-area-inset-bottom);
  }
}

@supports (padding-top: env(safe-area-inset-top)) {
  :root {
    --sat: env(safe-area-inset-top);
    --sab: env(safe-area-inset-bottom);
  }
}

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

html, body, #root {
  height: 100%;
  width: 100%;
  overflow: hidden;
}

body {
  font-family: 'Space Grotesk', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

.scrollable {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
  background: none;
  color: inherit;
}

input, textarea {
  font-family: inherit;
  border: none;
  outline: none;
  background: var(--bg-input);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 15px;
  width: 100%;
}

input::placeholder {
  color: var(--text-muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 15px;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-primary { background: var(--accent); color: #000; }
.btn-primary:hover { background: var(--accent-dim); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--text-dim); }
.btn-sm { padding: 8px 16px; font-size: 13px; }
.btn-full { width: 100%; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

/* ============ MAP ============ */
.map-container {
  width: 100%;
  height: 100%;
  position: relative;
}

.map-container .leaflet-container {
  width: 100%;
  height: 100%;
  background: #0a0a0a;
}

.leaflet-tile-pane {
  filter: brightness(0.7) contrast(1.1) saturate(0.3) hue-rotate(180deg) invert(1);
}

.leaflet-control-zoom a {
  background: var(--bg-card) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}

.leaflet-control-attribution {
  background: rgba(0,0,0,0.6) !important;
  color: var(--text-muted) !important;
  font-size: 10px !important;
}

.leaflet-control-attribution a {
  color: var(--text-dim) !important;
}

/* ============ MAP OVERLAYS ============ */
.map-overlay {
  position: absolute;
  z-index: 1000;
  pointer-events: auto;
}

.map-overlay-top {
  top: 16px;
  left: 16px;
  right: 16px;
}

.map-overlay-bottom {
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px;
  padding-bottom: 20px;
  padding-bottom: calc(16px + var(--sab));
}

/* ============ HUNT MAP TOP BAR + CLUES ============ */
.hunt-top-bar {
  position: absolute;
  z-index: 1000;
  top: 56px;
  top: calc(16px + var(--sat));
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}

.hunt-clue-wrap {
  position: absolute;
  z-index: 1000;
  top: 108px;
  top: calc(68px + var(--sat));
  left: 16px;
  right: 16px;
}

.clue-feed {
  max-height: 22vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.clue-item {
  background: rgba(20, 20, 20, 0.92);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.4;
  animation: slideUp 0.3s ease;
}

.clue-item .clue-hint {
  color: var(--warning);
  font-size: 12px;
  margin-top: 4px;
}

/* ============ PROXIMITY ============ */
.proximity-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: rgba(20, 20, 20, 0.92);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
}

.proximity-dots { display: flex; gap: 4px; }

.proximity-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.3s ease;
}

.proximity-dot.active {
  animation: pulse 1s ease infinite;
}

/* ============ QR SCANNER ============ */
.scanner-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2000;
  background: #000;
  display: flex;
  flex-direction: column;
}

.scanner-header {
  padding: 16px;
  padding-top: 56px;
  padding-top: calc(16px + var(--sat));
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.scanner-viewfinder {
  flex: 1;
  position: relative;
}

.scanner-instructions {
  padding: 24px 16px;
  padding-bottom: 40px;
  padding-bottom: calc(24px + var(--sab));
  text-align: center;
  color: var(--text-dim);
}

/* ============ CLAIM MODAL ============ */
.claim-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 3000;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.3s ease;
}

.claim-card {
  background: var(--bg-card);
  border: 2px solid var(--accent);
  border-radius: 20px;
  padding: 32px 24px;
  text-align: center;
  max-width: 360px;
  width: 100%;
  animation: bounceIn 0.5s ease;
}

.claim-card h2 { font-size: 24px; margin: 16px 0 8px; }
.claim-card .claim-emoji { font-size: 64px; display: block; }

/* ============ PAGE LAYOUTS ============ */
.page {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.page-header {
  padding: 16px;
  padding-top: 56px;
  padding-top: calc(16px + var(--sat));
  border-bottom: 1px solid var(--border);
}

.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

/* ============ BADGES ============ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-active { background: rgba(34,197,94,0.15); color: var(--accent); }
.badge-draft { background: rgba(136,136,136,0.15); color: var(--text-dim); }
.badge-claimed { background: rgba(139,92,246,0.15); color: var(--purple); }
.badge-completed { background: rgba(59,130,246,0.15); color: var(--blue); }

/* ============ TOAST ============ */
.toast {
  position: fixed;
  top: 56px;
  top: calc(16px + var(--sat));
  left: 50%;
  transform: translateX(-50%);
  z-index: 5000;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  animation: slideDown 0.3s ease;
  max-width: 90%;
}

.toast-success { background: var(--accent); color: #000; }
.toast-error { background: var(--danger); color: #fff; }

/* ============ ANIMATIONS ============ */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes bounceIn {
  0% { transform: scale(0.5); opacity: 0; }
  60% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

@keyframes slideDown {
  from { opacity: 0; transform: translate(-50%, -20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
