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

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Tipii brand defaults — overridden per hunt */
  --primary: #170F0C;
  --accent: #B79858;
  --bg: #FAF9F6;

  /* Tipii palette */
  --moss: #D6DAD4;
  --pistachio: #B79858;
  --honey: #E9BC69;
  --rust: #8B2517;
  --peach: #EFAA93;
  --terracotta: #D95940;
  --olivewood: #170F0C;
  --feather: #FAF9F6;

  --font-heading: 'Poppins', sans-serif;
  --font-body: 'Nunito Sans', sans-serif;
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-pill: 50px;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--olivewood);
  overflow: hidden;
  height: 100dvh;
}

h1, h2, h3 {
  font-family: var(--font-heading);
}

/* ── MAP PAGE ── */

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

header {
  background: var(--primary);
  color: var(--feather);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 1000;
}

#brand-logo {
  height: 32px;
  object-fit: contain;
}

#hunt-title {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 600;
  flex: 1;
}

#progress {
  font-family: var(--font-heading);
  font-size: 13px;
  background: var(--accent);
  color: var(--feather);
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  white-space: nowrap;
}

#map {
  flex: 1;
}

/* treasure markers */
.treasure-icon {
  background: var(--accent);
  border: 3px solid var(--feather);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 3px 12px rgba(23, 15, 12, 0.25);
  cursor: pointer;
  transition: transform 0.2s;
}

.treasure-icon:hover {
  transform: scale(1.15);
}

.treasure-icon.found {
  background: var(--moss);
  border-color: var(--pistachio);
}


/* ── REDEEM PAGE ── */

#redeem-app {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: auto;
  background: var(--bg);
}

.card {
  background: var(--feather);
  border-radius: var(--radius-lg);
  padding: 48px 32px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: 0 8px 32px rgba(23, 15, 12, 0.08);
  position: relative;
  overflow: hidden;
}

#redeem-logo {
  height: 44px;
  margin-bottom: 28px;
  object-fit: contain;
}

#redeem-loading p {
  font-family: var(--font-body);
  color: #888;
  font-size: 16px;
}

#redeem-title {
  font-family: var(--font-heading);
  font-size: 32px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
}

#redeem-treasure-name {
  font-family: var(--font-body);
  color: #888;
  margin-bottom: 28px;
  font-size: 16px;
}

#promo-box, #promo-box-already {
  background: var(--bg);
  border: 2px dashed var(--accent);
  border-radius: var(--radius-md);
  padding: 24px;
  margin: 24px 0;
}

#promo-label, #promo-label-already {
  display: block;
  font-family: var(--font-body);
  font-size: 14px;
  color: #888;
  margin-bottom: 10px;
}

#promo-code, #promo-code-already {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 3px;
  color: var(--primary);
  font-family: 'Poppins', monospace;
  margin-bottom: 16px;
  word-break: break-all;
}

.btn-accent {
  background: var(--accent);
  color: var(--feather);
  border: none;
  padding: 12px 28px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-heading);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-accent:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(183, 152, 88, 0.3);
}

.btn-accent:active {
  transform: scale(0.97);
}

.small {
  font-size: 12px;
  color: #aaa;
  margin-top: 18px;
  font-family: var(--font-body);
}

.back-link {
  display: inline-block;
  margin-top: 24px;
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  font-family: var(--font-heading);
  font-size: 14px;
  transition: color 0.2s;
}

.back-link:hover {
  color: var(--honey);
}

#redeem-already h1,
#redeem-error h1 {
  font-family: var(--font-heading);
  font-size: 28px;
  color: var(--primary);
  margin-bottom: 12px;
}

#redeem-already p,
#redeem-error p {
  color: #888;
  margin-bottom: 8px;
}

.hidden {
  display: none !important;
}

/* confetti */
.confetti-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  width: 8px;
  height: 8px;
  top: -10px;
  animation: confetti-fall 3s ease-out forwards;
}

@keyframes confetti-fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(500px) rotate(720deg); opacity: 0; }
}

/* ── BOTTOM CARDS TRAY ── */

#cards-tray {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1001;
  padding: 0 0 env(safe-area-inset-bottom, 12px);
  background: linear-gradient(transparent, rgba(23, 15, 12, 0.06) 30%);
  pointer-events: none;
}

#cards-scroll {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding: 16px 20px;
  pointer-events: auto;
  scrollbar-width: none;
}

#cards-scroll::-webkit-scrollbar {
  display: none;
}

.tray-card {
  flex: 0 0 260px;
  scroll-snap-align: start;
  background: var(--feather);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: 0 4px 20px rgba(23, 15, 12, 0.12);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  border: 2px solid transparent;
}

.tray-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(23, 15, 12, 0.16);
}

.tray-card--nearest {
  border-color: var(--accent);
}

.tray-card--found {
  opacity: 0.7;
}

.tray-card-image {
  width: 100%;
  height: 100px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 8px;
}

.tray-card-rank {
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
  margin-bottom: 6px;
}

.tray-card--nearest .tray-card-rank {
  color: var(--terracotta);
}

.tray-card-name {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 600;
  color: var(--olivewood);
  margin-bottom: 4px;
}

.tray-card-hint {
  font-family: var(--font-body);
  font-size: 13px;
  color: #888;
  margin-bottom: 8px;
  line-height: 1.4;
}

.tray-card-distance {
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 8px;
}

.tray-card-status {
  display: inline-block;
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
}

.tray-card-status.not-found {
  background: var(--honey);
  color: var(--olivewood);
}

.tray-card-status.found {
  background: var(--moss);
  color: var(--olivewood);
}

/* ── USER MARKER ── */

.user-marker {
  width: 16px;
  height: 16px;
  background: #4285F4;
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.3), 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* ── DASHBOARD ── */

#dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.dash-card {
  background: white;
  border: 1px solid var(--moss);
  border-radius: var(--radius-md);
  padding: 20px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.dash-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(23, 15, 12, 0.1);
}

.dash-card--add {
  border: 2px dashed var(--moss);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 160px;
}

.dash-card--add:hover {
  border-color: var(--accent);
}

.dash-add-icon {
  font-size: 36px;
  font-weight: 300;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 8px;
}

.dash-add-label {
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
}

.dash-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.dash-card-logo {
  height: 28px;
  object-fit: contain;
}

.dash-card-dot {
  width: 28px;
  height: 28px;
  border-radius: 8px;
}

.dash-card-brand {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  color: var(--olivewood);
  margin-bottom: 2px;
}

.dash-card-title {
  font-family: var(--font-body);
  font-size: 13px;
  color: #888;
  margin-bottom: 12px;
}

.dash-card-stats {
  display: flex;
  gap: 16px;
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 600;
  color: var(--olivewood);
}

.dash-card-tenants {
  margin-top: 8px;
  font-size: 11px;
  color: var(--accent);
  font-family: var(--font-body);
}

/* ── DETAIL VIEW ── */

.btn-back {
  background: none;
  border: none;
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  padding: 8px 0;
  transition: color 0.2s;
}

.btn-back:hover {
  color: var(--honey);
}

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 12px 0 20px;
  flex-wrap: wrap;
}

.detail-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.detail-logo {
  height: 40px;
  object-fit: contain;
}

.detail-header h2 {
  font-size: 20px;
  color: var(--olivewood);
  margin: 0;
}

/* ── ADMIN PAGE ── */

body.admin-body {
  overflow: auto;
  height: auto;
  background: var(--feather);
}

.admin-shell {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--moss);
}

.admin-header h1 {
  font-size: 22px;
  color: var(--olivewood);
}

.admin-section {
  margin-bottom: 32px;
}

.admin-section h2 {
  font-size: 16px;
  color: var(--olivewood);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-card {
  background: white;
  border: 1px solid var(--moss);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 12px;
}

.admin-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.admin-card-header h3 {
  font-size: 16px;
  color: var(--olivewood);
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.admin-grid.cols-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.admin-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-field.full {
  grid-column: 1 / -1;
}

.admin-field label {
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.admin-field input,
.admin-field select {
  font-family: var(--font-body);
  font-size: 14px;
  padding: 10px 12px;
  border: 1.5px solid var(--moss);
  border-radius: var(--radius-sm);
  background: var(--feather);
  color: var(--olivewood);
  outline: none;
  transition: border-color 0.2s;
}

.admin-field input:focus,
.admin-field select:focus {
  border-color: var(--accent);
}

.admin-field input[type="color"] {
  height: 42px;
  padding: 4px;
  cursor: pointer;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-outline:hover {
  background: var(--accent);
  color: var(--feather);
}

.btn-danger {
  background: transparent;
  color: var(--rust);
  border: 1.5px solid var(--rust);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-danger:hover {
  background: var(--rust);
  color: var(--feather);
}

.treasure-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--moss);
}

.treasure-row:last-child {
  border-bottom: none;
}

.treasure-row-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--feather);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}

.treasure-row-info {
  flex: 1;
}

.treasure-row-info strong {
  display: block;
  font-family: var(--font-heading);
  font-size: 14px;
}

.treasure-row-info span {
  font-size: 12px;
  color: #888;
}

.treasure-row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.qr-preview {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  border: 1px solid var(--moss);
  object-fit: contain;
  background: white;
}

.admin-empty {
  text-align: center;
  padding: 32px;
  color: #888;
  font-size: 14px;
}

.admin-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--olivewood);
  color: var(--feather);
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 9999;
}

.admin-toast.show {
  transform: translateY(0);
  opacity: 1;
}

.admin-toast.error {
  background: var(--rust);
}

/* ── HUNT HEADER ── */

.hunt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.hunt-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hunt-color-dot {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  flex-shrink: 0;
}

.hunt-header-title {
  font-size: 16px;
  color: var(--olivewood);
  margin: 0;
}

.hunt-header-meta {
  font-size: 12px;
  color: #888;
}

.hunt-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.hunt-badge {
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
}

.hunt-badge.active {
  background: #d4edda;
  color: #155724;
}

.hunt-badge.inactive {
  background: #f8d7da;
  color: #721c24;
}

/* ── TREASURE ROW THUMB ── */

.treasure-row-thumb {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--moss);
}

.treasure-row-meta {
  display: block;
  font-size: 11px;
  color: #aaa;
  margin-top: 2px;
}

/* ── HINT IMAGE DROPZONE ── */

.hint-dropzone {
  border: 2px dashed var(--moss);
  border-radius: var(--radius-sm);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.hint-dropzone:hover,
.hint-dropzone.dragover {
  border-color: var(--accent);
  background: rgba(183, 152, 88, 0.05);
}

.drop-label {
  font-family: var(--font-body);
  font-size: 13px;
  color: #888;
}

.hint-preview {
  margin-top: 8px;
  max-width: 200px;
  max-height: 120px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--moss);
}

.add-treasure-card {
  border: 2px dashed var(--moss);
  background: var(--bg);
}

.edit-hunt-card {
  border-left: 4px solid var(--accent);
}

.access-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 0;
}

.access-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--olivewood);
  background: var(--feather);
  border: 1.5px solid var(--moss);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.access-check:has(input:checked) {
  border-color: var(--accent);
  background: rgba(183, 152, 88, 0.08);
}

.access-check input {
  accent-color: var(--accent);
}

.edit-treasure-form {
  padding: 16px 0 16px 40px;
  border-bottom: 1px solid var(--moss);
  background: var(--bg);
  margin: 0 -20px;
  padding-left: 60px;
  padding-right: 20px;
}

/* ── LOGIN SCREEN ── */

.login-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--feather);
  padding: 24px;
}

.login-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 48px 36px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: 0 8px 32px rgba(23, 15, 12, 0.08);
}

.login-card h2 {
  font-size: 20px;
  color: var(--olivewood);
  margin-bottom: 4px;
}

/* ── LOADING SPINNER ── */

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--moss);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── LIGHTBOX ── */

#lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 24px;
  animation: fadeIn 0.2s ease;
}

#lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 12px;
  object-fit: contain;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4);
}

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

.tray-card-image {
  cursor: pointer;
}

/* responsive */
@media (min-width: 768px) {
  .tray-card {
    flex: 0 0 280px;
  }
}
