@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Lora:ital,wght@0,600;0,700;1,600&display=swap');

/* ─── CSS VARIABLES ─────────────────────────────────────── */
:root {
  --bg-deep: #0D1A06;
  --bg-main: #1A2E0B;
  --bg-card: #1F3610;
  --bg-card-2: #2A4A18;
  --bg-brown: #3E2716;
  --bg-brown-2: #2E1B0C;

  --gold: #F4C430;
  --gold-dim: #C9A028;
  --gold-glow: rgba(244, 196, 48, 0.25);
  --gold-glow-sm: rgba(244, 196, 48, 0.12);

  --text-cream: #FFF8E7;
  --text-muted: #A8B89A;
  --text-dim: #6B8060;

  --green-happy: #4CAF50;
  --yellow-mid: #FFC107;
  --red-sad: #F44336;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 999px;

  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-gold: 0 0 20px rgba(244, 196, 48, 0.3);
  --transition: all 0.2s ease;
}

/* ─── RESET ─────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
}

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background-color: var(--bg-deep);
  color: var(--text-cream);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a {
  color: var(--gold);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
}

/* ─── TYPOGRAPHY ─────────────────────────────────────────── */
h1,
h2,
h3 {
  font-family: 'Lora', serif;
}

h1 {
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  color: var(--gold);
}

h2 {
  font-size: clamp(1.2rem, 3vw, 1.6rem);
}

h3 {
  font-size: 1.1rem;
}

/* ─── UTILITIES ──────────────────────────────────────────── */
.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-sm {
  gap: 8px;
}

.gap-md {
  gap: 14px;
}

.gap-lg {
  gap: 20px;
}

.text-gold {
  color: var(--gold);
}

.text-muted {
  color: var(--text-muted);
}

.text-sm {
  font-size: 0.82rem;
}

.text-lg {
  font-size: 1.1rem;
}

.text-center {
  text-align: center;
}

.fw-bold {
  font-weight: 700;
}

.w-full {
  width: 100%;
}

.mt-sm {
  margin-top: 8px;
}

.mt-md {
  margin-top: 14px;
}

.mt-lg {
  margin-top: 20px;
}

.hidden {
  display: none !important;
}

/* ─── CARDS ──────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-card);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.card-brown {
  background: var(--bg-brown);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.card-gold {
  background: linear-gradient(135deg, #2A3C10, #1F2E08);
  border: 1.5px solid var(--gold-dim);
  box-shadow: var(--shadow-gold);
}

/* ─── BUTTONS ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: var(--radius-full);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none !important;
}

.btn-gold {
  background: linear-gradient(135deg, var(--gold), #E8A020);
  color: #1A0D00;
  box-shadow: 0 4px 16px rgba(244, 196, 48, 0.4);
}

.btn-gold:hover,
.btn-gold:focus {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(244, 196, 48, 0.55);
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--gold-dim);
  color: var(--gold);
}

.btn-outline:hover {
  background: var(--gold-glow-sm);
}

/* V4 Custom Colors */
.btn-outline[onclick*="startWalk"] {
  border-color: #4caf50;
  color: #4caf50;
}

.btn-outline[onclick*="startWalk"]:hover {
  background: rgba(76, 175, 80, 0.1);
}

.btn-outline[onclick*="las"] {
  border-color: #8bc34a;
  color: #8bc34a;
}

.btn-outline[onclick*="las"]:hover {
  background: rgba(139, 195, 74, 0.1);
}

.btn-outline[onclick*="clean"] {
  border-color: #03a9f4;
  color: #03a9f4;
}

.btn-outline[onclick*="clean"]:hover {
  background: rgba(3, 169, 244, 0.1);
}

.btn-outline[onclick*="play"] {
  border-color: #ff9800;
  color: #ff9800;
}

.btn-outline[onclick*="play"]:hover {
  background: rgba(255, 152, 0, 0.1);
}

.btn-green {
  background: linear-gradient(135deg, #3A8C3F, #2D6B31);
  color: #fff;
  box-shadow: 0 4px 14px rgba(76, 175, 80, 0.35);
}

.btn-green:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(76, 175, 80, 0.5);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.82rem;
}

.btn-lg {
  padding: 16px 30px;
  font-size: 1.05rem;
}

.btn-full {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* ─── PULSING GLOW (dzienna karma) ───────────────────────── */
@keyframes pulse-glow {

  0%,
  100% {
    box-shadow: 0 4px 16px rgba(76, 175, 80, 0.35);
  }

  50% {
    box-shadow: 0 4px 28px rgba(76, 175, 80, 0.7);
  }
}

.btn-pulse {
  animation: pulse-glow 2s ease-in-out infinite;
}

/* ─── PROGRESS BARS ──────────────────────────────────────── */
.progress-track {
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  height: 10px;
  overflow: hidden;
  width: 100%;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.5s ease;
}

.progress-gold {
  background: linear-gradient(90deg, var(--gold-dim), var(--gold));
}

.progress-green {
  background: linear-gradient(90deg, #2D6B31, #4CAF50);
}

.progress-yellow {
  background: linear-gradient(90deg, #B8860B, #FFC107);
}

.progress-red {
  background: linear-gradient(90deg, #8B0000, #F44336);
}

/* ─── BADGES / PILLS ─────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-gold {
  background: var(--gold-glow);
  color: var(--gold);
  border: 1px solid var(--gold-dim);
}

.badge-green {
  background: rgba(76, 175, 80, 0.15);
  color: #7DFF82;
  border: 1px solid rgba(76, 175, 80, 0.3);
}

.badge-silver {
  background: rgba(192, 192, 192, 0.15);
  color: #C0C0C0;
  border: 1px solid rgba(192, 192, 192, 0.3);
}

.badge-bronze {
  background: rgba(205, 127, 50, 0.15);
  color: #CD7F32;
  border: 1px solid rgba(205, 127, 50, 0.3);
}

.badge-red {
  background: rgba(244, 67, 54, 0.15);
  color: #FF8A80;
  border: 1px solid rgba(244, 67, 54, 0.3);
}

/* ─── TOP NAV ────────────────────────────────────────────── */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(13, 26, 6, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.nav-logo {
  font-family: 'Lora', serif;
  font-size: 1.1rem;
  color: var(--gold);
  font-weight: 700;
  white-space: nowrap;
}

.nav-karma {
  background: var(--gold-glow-sm);
  border: 1px solid var(--gold-dim);
  border-radius: var(--radius-full);
  padding: 5px 14px;
  font-weight: 700;
  color: var(--gold);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.nav-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--gold-dim);
  object-fit: cover;
  flex-shrink: 0;
}

.nav-avatar-placeholder {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--gold-dim);
  background: var(--bg-brown);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── BOTTOM NAV ─────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(13, 26, 6, 0.97);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  justify-content: space-around;
  padding: 10px 0 max(10px, env(safe-area-inset-bottom));
}

.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--text-dim);
  font-size: 0.68rem;
  font-weight: 600;
  text-decoration: none;
  transition: var(--transition);
  padding: 0 10px;
}

.bottom-nav a.active,
.bottom-nav a:hover {
  color: var(--gold);
}

.bottom-nav .nav-icon {
  font-size: 1.4rem;
}

/* ─── ANIMAL CARD ────────────────────────────────────────── */
.animal-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: var(--transition);
  cursor: pointer;
}

.animal-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.animal-card-img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
  background: var(--bg-card-2);
}

.animal-card-img-placeholder {
  width: 100%;
  aspect-ratio: 4/3;
  background: linear-gradient(135deg, var(--bg-card-2), var(--bg-brown));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.5rem;
}

.animal-card-body {
  padding: 14px;
}

.animal-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.animal-name {
  font-family: 'Lora', serif;
  font-size: 1.1rem;
  color: var(--text-cream);
  font-weight: 700;
}

.animal-species {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.level-badge {
  background: linear-gradient(135deg, var(--gold-dim), var(--gold));
  color: #1A0D00;
  border-radius: var(--radius-full);
  padding: 2px 10px;
  font-size: 0.75rem;
  font-weight: 800;
  white-space: nowrap;
}

.stats-row {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.feed-count {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 6px;
}

/* ─── ANIMALS GRID ───────────────────────────────────────── */
.animals-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  padding: 16px;
}

/* ─── ANIMAL CARDS ────────────────────────────────────────── */
.animal-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.animal-card:active {
  transform: scale(0.98);
}

.animal-card-img-placeholder {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--bg-brown);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.animal-card-img-placeholder img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.animal-card-body {
  padding: 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.animal-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.animal-name {
  font-family: 'Lora', serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-cream);
}

.animal-species {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.level-badge {
  font-size: 0.7rem;
  font-weight: 800;
  background: var(--bg-brown);
  color: var(--gold);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  border: 1px solid var(--gold-dim);
}

/* ─── LEADERBOARD LIST ───────────────────────────────────── */
.lb-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  margin-bottom: 8px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.lb-item.me {
  border-color: var(--gold-dim);
  background: rgba(244, 196, 48, 0.05);
}

.lb-rank {
  font-weight: 800;
  font-size: 1.1rem;
  min-width: 28px;
  text-align: center;
}

.lb-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bg-brown);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.lb-name {
  font-weight: 600;
  font-size: 0.9rem;
  flex: 1;
}

.lb-karma {
  font-weight: 700;
  color: var(--gold);
  font-size: 0.9rem;
  white-space: nowrap;
}

/* ─── TOAST NOTIFICATIONS ─────────────────────────────────── */
#toast-container {
  position: fixed;
  top: 80px;
  right: 16px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  animation: toast-in 0.3s ease;
  pointer-events: auto;
}

.toast.success {
  border-color: #4CAF50;
  color: #7DFF82;
}

.toast.error {
  border-color: #F44336;
  color: #FF8A80;
}

.toast.info {
  border-color: var(--gold-dim);
  color: var(--gold);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(40px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ─── SECTION HEADER ─────────────────────────────────────── */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 16px 8px;
}

.section-title {
  font-family: 'Lora', serif;
  font-size: 1.1rem;
  color: var(--text-cream);
}

.section-link {
  font-size: 0.8rem;
  color: var(--gold);
}

/* ─── KARMA BANNER ───────────────────────────────────────── */
.karma-banner {
  margin: 14px 16px;
  padding: 16px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #2A3C10, #1F2E08);
  border: 1.5px solid var(--gold-dim);
  box-shadow: var(--shadow-gold);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.karma-amount {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--gold);
}

.karma-label {
  font-size: 0.78rem;
  color: var(--text-muted);
}

#daily-btn {
  flex-shrink: 0;
}

/* ─── SPINNER ────────────────────────────────────────────── */
.spinner-wrap {
  display: flex;
  justify-content: center;
  padding: 40px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ─── MODAL ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade-in 0.2s ease;
}

.modal-overlay.hidden {
  display: none !important;
}

.modal-box {
  background: var(--bg-main);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 24px 20px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slide-up 0.3s ease;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes slide-up {
  from {
    transform: translateY(60px);
    opacity: 0;
  }
}

/* ─── PAGE PADDING (above bottom nav) ───────────────────── */
.page-content {
  padding-bottom: 80px;
}

/* ─── RESPONSIVE ─────────────────────────────────────────── */
@media (min-width: 640px) {
  .animals-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  body {
    max-width: 768px;
    margin: 0 auto;
  }

  .bottom-nav {
    max-width: 768px;
    margin: 0 auto;
    left: 50%;
    transform: translateX(-50%);
    right: auto;
    width: 100%;
  }
}

@media (max-width: 360px) {
  .animals-grid {
    grid-template-columns: 1fr;
  }

  .karma-banner {
    flex-direction: column;
    align-items: flex-start;
  }
}