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

:root {
  --paper: #FAF3E7;
  --paper-dot: #F0E6D2;
  --ink: #1B1B2F;
  --coral: #FF6B5B;
  --coral-dark: #E14F40;
  --lime: #B7D84A;
  --lime-dark: #8FAE2E;
  --sky: #6EC1E4;
  --grape: #9B72CF;
  --gold: #F4B740;
  --card: #FFFFFF;
  --radius: 18px;
  --shadow-off: 4px 4px 0 var(--ink);
  --shadow-off-sm: 2.5px 2.5px 0 var(--ink);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background-color: var(--paper);
  background-image: radial-gradient(var(--paper-dot) 1.4px, transparent 1.4px);
  background-size: 18px 18px;
  color: var(--ink);
  font-family: 'Nunito', sans-serif;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, .display {
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-weight: 800;
  letter-spacing: 0.2px;
  margin: 0;
}

button, input, select {
  font-family: inherit;
}

a { color: var(--coral-dark); }

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: 84px;
  position: relative;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  position: sticky;
  top: 0;
  background: var(--paper);
  z-index: 20;
  border-bottom: 3px solid var(--ink);
}
.topbar .brand {
  font-size: 22px;
  transform: rotate(-2deg);
  display: inline-block;
}
.brand .zig { color: var(--coral); }
.coins-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--gold);
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  padding: 5px 12px;
  font-weight: 800;
  font-family: 'Baloo 2', sans-serif;
  box-shadow: var(--shadow-off-sm);
}
.icon-btn {
  border: 2.5px solid var(--ink);
  background: var(--card);
  border-radius: 999px;
  width: 36px; height: 36px;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: var(--shadow-off-sm);
  font-size: 16px;
}
.icon-btn:active { transform: translate(2px, 2px); box-shadow: none; }

/* ---------- Generic sections ---------- */
.screen { padding: 16px; }
.section-title {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--ink);
  opacity: 0.65;
  margin: 22px 0 10px;
  font-weight: 800;
}
.section-title:first-child { margin-top: 4px; }

/* ---------- Sticker cards ---------- */
.sticker {
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow-off);
  padding: 16px;
  margin-bottom: 16px;
}
.sticker.tilt-l { transform: rotate(-0.8deg); }
.sticker.tilt-r { transform: rotate(0.8deg); }

/* ---------- Buttons ---------- */
.btn {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 700;
  font-size: 15px;
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  padding: 10px 16px;
  background: var(--card);
  box-shadow: var(--shadow-off-sm);
  cursor: pointer;
  color: var(--ink);
  transition: transform 0.05s;
}
.btn:active { transform: translate(2.5px, 2.5px); box-shadow: none; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-primary { background: var(--coral); color: white; }
.btn-lime { background: var(--lime); }
.btn-sky { background: var(--sky); color: white; }
.btn-grape { background: var(--grape); color: white; }
.btn-gold { background: var(--gold); }
.btn-ghost { background: transparent; box-shadow: none; }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; box-shadow: 2px 2px 0 var(--ink); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-weight: 800;
  font-family: 'Baloo 2', sans-serif;
  font-size: 13px;
  margin-bottom: 6px;
  opacity: 0.8;
}
.field input, .field select {
  width: 100%;
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 15px;
  background: var(--card);
}
.field input:focus, .field select:focus, button:focus-visible, .btn:focus-visible {
  outline: 3px solid var(--grape);
  outline-offset: 1px;
}

/* ---------- Auth ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
}
.auth-hero-img { width: 150px; margin: 0 auto 6px; display: block; filter: drop-shadow(3px 4px 0 var(--ink)); }
.auth-wrap h1 { font-size: 34px; margin-bottom: 4px; }
.auth-wrap p.tag { margin: 0 0 22px; opacity: 0.75; font-weight: 600; }
.auth-card { width: 100%; max-width: 340px; text-align: left; }
.auth-toggle { display: flex; gap: 8px; margin-bottom: 18px; }
.auth-toggle .btn { flex: 1; }
.auth-toggle .btn.active { background: var(--ink); color: var(--paper); }
.error-box {
  background: #FFE1DC; border: 2.5px solid var(--coral-dark); color: var(--coral-dark);
  padding: 10px 12px; border-radius: 12px; font-weight: 700; font-size: 14px; margin-bottom: 14px;
}
.hint-box {
  background: #EAF6E0; border: 2.5px solid var(--lime-dark); color: #4C6B1F;
  padding: 10px 12px; border-radius: 12px; font-weight: 700; font-size: 13.5px; margin-bottom: 14px;
}

/* ---------- Starter picker ---------- */
.species-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
.species-card {
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  background: var(--card);
  padding: 10px;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow-off-sm);
}
.species-card img { width: 100%; max-width: 100px; margin: 0 auto; display: block; }
.species-card.selected { background: #FFF1C9; box-shadow: var(--shadow-off); outline: 3px solid var(--gold); }
.species-card .label { font-family: 'Baloo 2', sans-serif; font-weight: 700; font-size: 13px; margin-top: 4px; }

/* ---------- Pet card ---------- */
.pet-card { position: relative; }
.pet-card-head { display: flex; align-items: center; gap: 12px; }
.pet-card-head img { width: 76px; filter: drop-shadow(2px 3px 0 rgba(0,0,0,0.15)); }
.pet-card-head .info { flex: 1; }
.pet-name { font-size: 20px; }
.pet-sub { font-size: 12.5px; opacity: 0.65; font-weight: 700; }
.lvl-badge {
  display: inline-block; background: var(--grape); color: white; font-family: 'Baloo 2', sans-serif;
  font-weight: 700; font-size: 12px; padding: 2px 9px; border-radius: 999px; margin-left: 6px;
}

.stat-row { margin-top: 12px; }
.stat-label { display: flex; justify-content: space-between; font-size: 12.5px; font-weight: 800; margin-bottom: 3px; }
.stat-track {
  height: 12px; border-radius: 999px; background: #EFE7D6; border: 2px solid var(--ink); overflow: hidden;
}
.stat-fill { height: 100%; border-radius: 999px; }
.stat-fill.hunger { background: var(--coral); }
.stat-fill.happiness { background: var(--gold); }
.stat-fill.energy { background: var(--sky); }
.stat-fill.cleanliness { background: var(--lime); }
.stat-fill.low { background: repeating-linear-gradient(45deg, #E14F40, #E14F40 6px, #ff8a80 6px, #ff8a80 12px); }

.pet-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-top: 14px; }
.pet-actions .btn { padding: 9px 4px; font-size: 12.5px; }

.egg-banner {
  display: flex; align-items: center; gap: 10px; background: #F3E9FF; border: 2.5px dashed var(--grape);
  border-radius: 14px; padding: 10px 12px; font-weight: 700; font-size: 13.5px;
}

/* ---------- Tab nav ---------- */
.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  max-width: 480px;
  margin: 0 auto;
  background: var(--card);
  border-top: 3px solid var(--ink);
  display: flex;
  z-index: 30;
}
.tabbar button {
  flex: 1;
  background: none;
  border: none;
  padding: 10px 4px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-family: 'Baloo 2', sans-serif;
  font-weight: 700;
  font-size: 10.5px;
  color: var(--ink);
  opacity: 0.55;
  cursor: pointer;
}
.tabbar button .emoji { font-size: 20px; }
.tabbar button.active { opacity: 1; color: var(--coral-dark); }
.tabbar button.active .emoji { transform: translateY(-2px); }

/* ---------- Marketplace / trades lists ---------- */
.listing {
  display: flex; align-items: center; gap: 10px;
  border: 2.5px solid var(--ink); border-radius: 14px; padding: 10px; margin-bottom: 10px; background: var(--card);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.listing img { width: 46px; }
.listing .meta { flex: 1; }
.listing .title { font-weight: 800; font-family: 'Baloo 2', sans-serif; font-size: 14px; }
.listing .sub { font-size: 12px; opacity: 0.65; font-weight: 700; }
.price-tag {
  background: var(--gold); border: 2px solid var(--ink); border-radius: 999px; padding: 4px 10px;
  font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 13px; white-space: nowrap;
}
.badge {
  display: inline-block; font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 999px; border: 2px solid var(--ink);
}
.badge.pending { background: #FFF1C9; }
.badge.accepted { background: #EAF6E0; }
.badge.declined, .badge.cancelled { background: #FFE1DC; }

.tabs-sub { display: flex; gap: 8px; margin-bottom: 14px; }
.tabs-sub .btn { flex: 1; }
.tabs-sub .btn.active { background: var(--ink); color: var(--paper); }

.pet-pick-list { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 6px; }
.pet-pick {
  flex: 0 0 auto; width: 78px; text-align: center; border: 2.5px solid var(--ink); border-radius: 14px;
  padding: 8px 4px; cursor: pointer; background: var(--card);
}
.pet-pick img { width: 100%; }
.pet-pick.selected { background: #FFF1C9; outline: 2.5px solid var(--gold); }
.pet-pick .name { font-size: 10.5px; font-weight: 800; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Toast ---------- */
#toast-wrap {
  position: fixed; top: 10px; left: 50%; transform: translateX(-50%);
  z-index: 100; display: flex; flex-direction: column; gap: 8px; width: calc(100% - 32px); max-width: 448px;
}
.toast {
  border: 2.5px solid var(--ink); border-radius: 14px; padding: 10px 14px; font-weight: 700; font-size: 13.5px;
  box-shadow: var(--shadow-off-sm); animation: slide-in 0.18s ease-out;
}
.toast.ok { background: #EAF6E0; }
.toast.err { background: #FFE1DC; }
@keyframes slide-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

.empty-state { text-align: center; padding: 30px 10px; opacity: 0.6; font-weight: 700; }
.empty-state .emoji { font-size: 34px; display: block; margin-bottom: 6px; }

.muted { opacity: 0.6; font-size: 12.5px; font-weight: 700; }
.center { text-align: center; }
.mt8{margin-top:8px}.mt12{margin-top:12px}.mt16{margin-top:16px}.mb0{margin-bottom:0}

.install-banner {
  display: flex; align-items: center; gap: 10px; background: var(--sky); color: white;
  border: 2.5px solid var(--ink); border-radius: 14px; padding: 10px 12px; margin-bottom: 16px; font-weight: 700; font-size: 13px;
}
.install-banner button { margin-left: auto; }

.spinner {
  width: 18px; height: 18px; border: 3px solid var(--ink); border-top-color: transparent; border-radius: 50%;
  animation: spin 0.6s linear infinite; display: inline-block; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Modern smooth touches ---------- */
.stat-fill { transition: width 0.5s cubic-bezier(.34,1.56,.64,1); }

.pet-img { animation: idleBob 2.4s ease-in-out infinite; }
@keyframes idleBob {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-4px) rotate(-1.5deg); }
}
.pet-img.bounce { animation: petBounce 0.5s cubic-bezier(.36,1.8,.5,1); }
@keyframes petBounce {
  0% { transform: scale(1) rotate(0deg); }
  30% { transform: scale(1.12) rotate(-4deg); }
  55% { transform: scale(0.96) rotate(3deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.float-emoji {
  position: fixed;
  font-size: 22px;
  pointer-events: none;
  z-index: 200;
  animation: floatUp 0.9s ease-out forwards;
}
@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, 0) scale(0.6); }
  15% { opacity: 1; transform: translate(-50%, -10px) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -70px) scale(1); }
}

.btn { transition: transform 0.08s ease, box-shadow 0.08s ease; }
.sticker { transition: transform 0.15s ease; }
.icon-btn, .price-tag, .badge { transition: transform 0.1s ease; }

@media (hover: hover) {
  .btn:hover:not(:disabled) { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--ink); }
  .listing:hover { transform: translateY(-2px); box-shadow: var(--shadow-off-sm); }
  .species-card:hover, .pet-pick:hover { transform: translateY(-2px); }
}

@media (prefers-reduced-motion: reduce) {
  .fade-in, .pet-img.bounce, .float-emoji { animation: none !important; }
  .btn, .stat-fill { transition: none !important; }
  .pet-img { animation: none !important; }
  .habitat-pet { transition: none !important; }
}

/* ---------- Veldjes (habitats) ---------- */
.habitat-scene {
  position: relative;
  height: 150px;
  border-radius: 14px;
  border: 3px solid var(--ink);
  overflow: hidden;
  margin-top: 10px;
  box-shadow: var(--shadow-off-sm);
}
.theme-tuin { background: linear-gradient(to bottom, #bfe8ff 0%, #bfe8ff 58%, #8fd14f 58%, #67a82b 100%); }
.theme-weiland { background: linear-gradient(to bottom, #d7f3ff 0%, #d7f3ff 48%, #c7e86b 48%, #9dc236 100%); }
.theme-speeltuin { background: linear-gradient(to bottom, #ffe1f0 0%, #ffe1f0 52%, #ffd166 52%, #f0a93a 100%); }

.habitat-deco {
  position: absolute;
  font-size: 26px;
  opacity: 0.9;
  pointer-events: none;
  filter: drop-shadow(1px 2px 0 rgba(0,0,0,0.15));
}

.habitat-pet {
  position: absolute;
  bottom: 8px;
  width: 58px;
  left: 20px;
  transition: left 2.3s ease-in-out;
}
.habitat-pet img { width: 100%; display: block; }
.habitat-empty {
  display: flex; align-items: center; justify-content: center; height: 100%;
  font-weight: 800; font-family: 'Baloo 2', sans-serif; color: rgba(27,27,47,0.55); text-align: center; padding: 0 20px;
}

.habitat-card { margin-bottom: 18px; }
.habitat-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.habitat-card-head .title { font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 16px; }

/* ---------- Interactieve wasbeurt ---------- */
.wash-panel {
  margin-top: 12px;
  border: 2.5px dashed var(--sky);
  border-radius: 14px;
  padding: 12px;
  background: #EAF7FF;
}
.wash-stage {
  height: 110px;
  display: flex; align-items: flex-end; justify-content: center;
  background: linear-gradient(to bottom, #d7f0ff 0%, #d7f0ff 70%, #bfe4ff 70%, #bfe4ff 100%);
  border: 2.5px solid var(--ink); border-radius: 12px; overflow: hidden; position: relative;
}
.wash-stage .pet-img { width: 84px; margin-bottom: 6px; }
.wash-stage::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: 0; height: 14px;
  background: repeating-linear-gradient(90deg, #9fd7ff 0 10px, #bfe4ff 10px 20px);
  opacity: 0.8;
}
