:root {
  --bg: #e3efdd;
  --paper: #f7fbf3;
  --card: #f1f8ec;
  --line: #bcd6b4;
  --locked: #dbe6d6;
  --green: #2c7a4b;
  --green-dark: #1d5a35;
  --text: #1c3325;
  --muted: #587261;
  --blue: #2f80ba;
  --blue-deep: #1f6296;
  --blue-light: #d2e8f5;
  --sand: #f0dfb4;
  --wood: #b98a5a;
  --wood-dark: #8a6238;
  --danger: #b3432f;
  /* Capacitor 8 (Android) --safe-area-inset-* változókat ad, böngészőben az env() működik */
  --safe-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
  --safe-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body { overscroll-behavior-y: none; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
input { -webkit-user-select: text; user-select: text; }
body {
  color: var(--text);
  font: 16px/1.4 ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* finom mancsnyom-minta a háttéren */
  background-color: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cg fill='%23d3e6cc' opacity='.7'%3E%3Cg transform='translate(34 40) rotate(-18) scale(1)'%3E%3Cellipse cy='4' rx='8' ry='6.5'/%3E%3Cellipse cx='-9.5' cy='-2' rx='3' ry='4.2' transform='rotate(-20 -9.5 -2)'/%3E%3Cellipse cx='-3.6' cy='-8.5' rx='3.2' ry='4.6'/%3E%3Cellipse cx='3.6' cy='-8.5' rx='3.2' ry='4.6'/%3E%3Cellipse cx='9.5' cy='-2' rx='3' ry='4.2' transform='rotate(20 9.5 -2)'/%3E%3C/g%3E%3Cg transform='translate(104 108) rotate(22) scale(1)'%3E%3Cellipse cy='4' rx='8' ry='6.5'/%3E%3Cellipse cx='-9.5' cy='-2' rx='3' ry='4.2' transform='rotate(-20 -9.5 -2)'/%3E%3Cellipse cx='-3.6' cy='-8.5' rx='3.2' ry='4.6'/%3E%3Cellipse cx='3.6' cy='-8.5' rx='3.2' ry='4.6'/%3E%3Cellipse cx='9.5' cy='-2' rx='3' ry='4.2' transform='rotate(20 9.5 -2)'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
[hidden] { display: none !important; }
h2 { margin: 0 0 12px; font-size: 1.4rem; font-weight: 800; letter-spacing: -.01em; }
h3 { margin: 0 0 6px; font-size: 1.05rem; font-weight: 700; }
p { margin: 0 0 8px; }
svg { flex: none; }
.label { font-size: .75rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin: 12px 0 6px; }
.card > .label:first-child, .goal-text > .label:first-child { margin-top: 0; }
.small { font-size: .85rem; color: var(--muted); }
.center { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 8px; }
.error { color: var(--danger); font-weight: 700; }

/* ---------- Layout ---------- */
#app { max-width: 520px; margin: 0 auto; min-height: 100vh; }
#topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  background: var(--paper);
}
#topbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -7px; height: 8px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='8'%3E%3Cpath d='M0 0H24V2Q18 8 12 2T0 2Z' fill='%23f7fbf3'/%3E%3C/svg%3E") repeat-x;
}
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who strong { display: block; }
.who span { font-size: .85rem; color: var(--muted); }
.rank {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  padding: 5px 12px; border-radius: 999px; background: var(--green); color: #fff; font-size: .85rem; font-weight: 700;
  border: 2px solid var(--paper);
}
#screen { padding: 18px 16px calc(92px + var(--safe-bottom)); }
#topbar[hidden] + #screen { padding-top: calc(18px + var(--safe-top)); }

.avatar {
  width: 44px; height: 44px; overflow: hidden; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--blue-light); border: 2px solid var(--blue); font-size: 24px; flex: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.big { width: 88px; height: 88px; font-size: 44px; }

/* ---------- Alsó navigáció ---------- */
#nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; justify-content: center;
  background: var(--paper); border-top: 2px solid var(--line);
  padding-bottom: var(--safe-bottom);
}
#nav button {
  flex: 1; max-width: 78px; min-height: 58px; padding: 7px 0 5px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: 0; font: inherit; font-size: .6rem; color: var(--muted);
}
#nav button.active { color: var(--blue-deep); font-weight: 800; }
#nav button.active svg { background: var(--blue-light); border-radius: 12px; padding: 3px 8px; box-sizing: content-box; }
.nav-ico { position: relative; display: inline-flex; }
.badge-dot {
  position: absolute; top: -1px; right: -3px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--danger); border: 2px solid var(--paper);
}

/* ---------- Kártyák, gombok ---------- */
.card { background: var(--paper); border: 2px solid var(--line); border-radius: 18px; padding: 14px; margin-bottom: 12px; }
.card[data-action] { cursor: pointer; }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 48px; padding: 10px 16px; margin: 8px 0 0;
  font: inherit; font-weight: 700; text-align: center;
  color: var(--green-dark); background: var(--paper); border: 2px solid var(--green); border-radius: 14px;
}
.btn.primary { background: var(--green); color: #fff; border-color: var(--green-dark); box-shadow: 0 3px 0 var(--green-dark); }
.btn.big { min-height: 62px; font-size: 1.15rem; margin: 0 0 14px; }
.btn.ghost { border-color: var(--line); font-weight: 600; }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.file { width: auto; min-height: 40px; padding: 6px 14px; margin: 0; }
.btn:active { transform: translateY(2px); box-shadow: none; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

/* ---------- Kezdőképernyő ---------- */
.hero-wrap { position: relative; margin-bottom: 40px; }
.hero { position: relative; height: 210px; overflow: hidden; border-radius: 24px; border: 3px solid var(--paper); background: var(--blue-light); }
.hero-svg { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
.hero-top { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; justify-content: space-between; align-items: flex-start; }
.sign {
  position: relative; display: flex; flex-direction: column; padding: 6px 16px 6px 22px;
  background: var(--wood); border: 2px solid var(--wood-dark); border-radius: 10px; color: #fff8e6;
}
.sign::before { content: ""; position: absolute; left: 8px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: var(--wood-dark); }
.sign strong { font-size: 1.15rem; line-height: 1.2; }
.sign span { font-size: .8rem; opacity: .9; }
.hero-avatar { position: absolute; left: 18px; bottom: -30px; width: 72px; height: 72px; font-size: 38px; border: 4px solid var(--paper); box-shadow: 0 0 0 2px var(--blue); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.stat {
  display: flex; flex-direction: column; align-items: center; text-align: center; padding: 10px 4px;
  background: var(--paper); border: 2px solid var(--line); border-radius: 16px; color: var(--blue);
}
.stat strong { font-size: 1.15rem; color: var(--text); margin-top: 2px; }
.stat span { font-size: .72rem; color: var(--muted); }

.bar-head { display: flex; justify-content: space-between; margin-bottom: 4px; }
.lake-bar { height: 16px; margin: 6px 0; border-radius: 999px; overflow: hidden; background: var(--blue-light); border: 2px solid var(--blue); }
.lake-bar span {
  display: block; height: 100%; min-width: 0; background-color: var(--blue);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='12'%3E%3Cpath d='M0 6Q6 2 12 6T24 6' fill='none' stroke='white' stroke-opacity='.5' stroke-width='1.6'/%3E%3C/svg%3E");
}

.goal { display: flex; align-items: center; gap: 14px; }
.goal-text { flex: 1; min-width: 0; }
.goal-art { flex: none; width: 104px; border-radius: 12px; overflow: hidden; border: 2px solid var(--line); }
.goal-badge { flex: none; width: 76px; }
.goal-art .card-svg { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; }
.goal-art img { display: block; width: 100%; height: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.event-thumb { position: relative; }

/* ---------- Gyűjtemény (kártyák) ---------- */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.tile { display: flex; flex-direction: column; padding: 6px 6px 10px; font: inherit; text-align: left; border-radius: 18px; color: var(--text); }
.tile.got { background: var(--paper); border: 2px solid var(--green); box-shadow: 0 3px 0 var(--green); }
.tile.locked { background: var(--locked); border: 2px dashed var(--line); color: var(--muted); }
.tile-art { display: block; border-radius: 12px; overflow: hidden; }
.tile-art .card-svg { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; }
.tile-meta { display: flex; flex-direction: column; padding: 8px 6px 0; }
.tile-meta small { font-size: .7rem; font-weight: 700; color: var(--blue); }
.tile.locked .tile-meta small { color: var(--muted); }
.tile-meta strong { font-size: .95rem; }

/* ---------- Jelvények ---------- */
.badge-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.badge-tile {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 4px 8px;
  font: inherit; text-align: center; color: var(--text);
  background: var(--paper); border: 2px solid var(--line); border-radius: 16px;
}
.badge-tile.locked { background: var(--locked); color: var(--muted); border-style: dashed; }
.badge-tile strong { font-size: .8rem; line-height: 1.15; }
.badge-tile small { font-size: .7rem; color: var(--muted); }
.badge-tile.got small { color: var(--green); font-weight: 700; }
.badge-wrap { width: 100%; max-width: 92px; }
.badge-svg { display: block; width: 100%; height: auto; }
.mini-badge { display: inline-block; width: 22px; height: 22px; }
.mini-badge .badge-svg { width: 22px; height: 22px; }

/* ---------- Előzmények, beállítások ---------- */
.visit-head { display: flex; justify-content: space-between; margin-bottom: 4px; }
.icons { font-size: 1.3rem; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.pill { display: inline-flex; align-items: center; gap: 6px; background: var(--blue-light); border-radius: 999px; padding: 3px 10px; font-size: .85rem; }
.empty { text-align: center; }
.empty-art { width: 60%; margin: 0 auto 10px; border-radius: 14px; overflow: hidden; }
.empty-art .card-svg { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; }
.dog-row { display: flex; align-items: center; gap: 12px; }
.row-btn {
  display: flex; justify-content: space-between; gap: 8px; width: 100%; min-height: 48px; margin-bottom: 8px; padding: 10px 14px;
  font: inherit; font-size: .9rem; color: var(--text); text-align: left; background: var(--bg); border: 2px solid var(--line); border-radius: 14px;
}
.row-btn span:last-child { font-size: .8rem; color: var(--muted); }
.row-btn.active { border-color: var(--blue); background: var(--blue-light); font-weight: 700; }

/* ---------- Programok ---------- */
.event-card { width: 100%; padding: 0; overflow: hidden; display: block; text-align: left; font: inherit; color: var(--text); cursor: pointer; }
.event-card.new { border-color: var(--green); box-shadow: 0 3px 0 var(--green); }
.event-photo { position: relative; display: block; width: 100%; aspect-ratio: 16 / 10; background: var(--blue-light); overflow: hidden; }
.event-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.event-photo .card-svg { display: block; width: 100%; height: 100%; }
.event-body { display: flex; flex-direction: column; gap: 3px; padding: 12px 14px 14px; }
.event-body strong { font-size: 1rem; }
.event-type { align-self: flex-start; }
.new-tag {
  position: absolute; top: 8px; left: 8px; z-index: 1;
  background: var(--green); color: #fff; font-size: .68rem; font-weight: 800; letter-spacing: .02em;
  padding: 3px 9px; border-radius: 999px; box-shadow: 0 2px 0 var(--green-dark);
}
.offline-banner {
  display: flex; align-items: center; gap: 8px; background: var(--sand); color: #6b4a1f;
  border: 2px solid var(--wood); border-radius: 14px; padding: 10px 14px; margin-bottom: 12px;
  font-size: .85rem; font-weight: 600;
}
.offline-banner svg { flex: none; }

/* ---------- Modal ---------- */
#overlay { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 10; display: flex; align-items: flex-end; justify-content: center; }
.backdrop { position: absolute; top: 0; right: 0; bottom: 0; left: 0; background: rgba(16, 48, 66, .55); }
.sheet {
  position: relative; width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto;
  padding: 22px 16px calc(20px + var(--safe-bottom));
  background: var(--paper); border: 3px solid var(--line); border-bottom: 0; border-radius: 24px 24px 0 0;
}
.sheet::before { content: ""; position: absolute; top: 8px; left: 50%; width: 44px; height: 5px; margin-left: -22px; border-radius: 3px; background: var(--line); }
.sheet .btn:first-of-type { margin-top: 12px; }
.welcome-art { height: 176px; margin: -10px -4px 12px; border-radius: 16px; overflow: hidden; position: relative; }
.welcome-art .hero-svg { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }

.detail { text-align: center; }
.detail-art { border-radius: 16px; overflow: hidden; border: 3px solid var(--line); margin-bottom: 14px; }
.detail-art .card-svg { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; }
.detail-art img { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; }
.detail.got .detail-art { border-color: var(--green); }
.detail-badge { width: 190px; margin: 4px auto 12px; }
.status { font-size: .85rem; font-weight: 700; color: var(--blue); }
.detail.locked .status { color: var(--muted); }

/* Ünneplés */
.celebrate { text-align: center; }
.win { position: relative; margin: 0 0 18px; padding: 8px 0; }
.win-art { position: relative; width: 66%; margin: 0 auto 10px; border-radius: 16px; overflow: hidden; border: 3px solid var(--green); animation: pop .5s ease-out both; }
.win-art .card-svg { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; }
.win-badge { position: relative; width: 150px; margin: 0 auto 8px; animation: pop .55s ease-out both; }
.win .label { margin-top: 0; }
.rank-win { padding: 14px; background: var(--blue-light); border-radius: 16px; }
.rank-win h3 { display: inline-flex; align-items: center; gap: 8px; margin: 0; color: var(--blue-deep); }
.rings { position: absolute; top: 50%; left: 50%; width: 170px; height: 170px; margin: -105px 0 0 -85px; pointer-events: none; }
.rings i { position: absolute; top: 0; right: 0; bottom: 0; left: 0; border: 3px solid var(--blue); border-radius: 50%; opacity: 0; animation: ring 1.8s ease-out infinite; }
.rings i + i { animation-delay: .9s; }

/* ---------- Űrlapok ---------- */
label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: 10px; }
input[type="text"], input[type="date"], input[type="time"] {
  display: block; width: 100%; min-height: 48px; margin-top: 4px; padding: 10px 12px;
  font: inherit; font-size: 16px; color: var(--text);
  background: #fff; border: 2px solid var(--line); border-radius: 12px;
}
#v-note { margin-top: 12px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 44px; padding: 8px 14px; font: inherit; color: var(--text);
  background: var(--paper); border: 2px solid var(--line); border-radius: 999px;
}
.chip.on { background: var(--blue); border-color: var(--blue-deep); color: #fff; }

#toast {
  position: fixed; left: 50%; bottom: calc(76px + var(--safe-bottom)); z-index: 20; transform: translateX(-50%);
  padding: 10px 18px; border-radius: 999px; background: var(--blue-deep); color: #fff; font-weight: 700; white-space: nowrap;
}

/* ---------- Finom mozgás ---------- */
@keyframes drift { from { transform: translateX(0); } to { transform: translateX(-24px); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.06); } 100% { transform: scale(1); opacity: 1; } }
@keyframes ring { 0% { transform: scale(.5); opacity: .6; } 100% { transform: scale(1.5); opacity: 0; } }
.drift { animation: drift 6s ease-in-out infinite alternate; }
.drift-slow { animation: drift 14s ease-in-out infinite alternate; }
.bob { animation: bob 2.6s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) {
  .drift, .drift-slow, .bob, .win-art, .win-badge, .rings i { animation: none; }
}
