:root {
  --bg: #f1faf4;
  --surface: #ffffff;
  --surface-2: #e3f5ea;
  --text: #10251a;
  --muted: #587063;
  --border: #d3ebdc;
  --accent: #129b4a;
  --accent-2: #22c55e;
  --accent-ink: #ffffff;
  --danger: #e5484d;
  --due: #ff9f1c;
  --shadow: 0 6px 20px rgba(20, 90, 50, .10);
  --radius: 18px;
  --nav-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1610;
    --surface: #13241a;
    --surface-2: #1b3426;
    --text: #e8f7ee;
    --muted: #93b4a1;
    --border: #234531;
    --accent: #34d27a;
    --accent-2: #4ade80;
    --shadow: 0 6px 20px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 500 15px/1.4 Nunito, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
[hidden] { display: none !important; }

#app { max-width: 560px; margin: 0 auto; }
.center-screen { min-height: 100dvh; display: grid; place-content: center; justify-items: center; gap: 12px; padding: 24px; text-align: center; }
.big-emoji { font-size: 48px; line-height: 1; }
.bounce { animation: bounce 1s ease-in-out infinite; }
@keyframes bounce { 50% { transform: translateY(-10px) rotate(-8deg); } }

/* ---------- gombok, kártyák, űrlapok */
.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 14px;
  padding: 10px 14px;
  font-weight: 800;
  transition: transform .1s, background .2s;
}
.btn:active { transform: scale(.96); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-ink); border-color: transparent; }
.btn.on { background: var(--surface-2); border-color: var(--accent); }
.btn.block { display: block; width: 100%; }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 10px; }
.btn.grow { flex: 1; }
.btn.danger-ghost { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: transparent; }
.btn:disabled { opacity: .6; }
.link { background: none; border: 0; color: var(--accent); font-weight: 800; padding: 0; }
.icon-btn { background: none; border: 0; width: 36px; height: 36px; border-radius: 10px; font-size: 17px; color: var(--muted); flex-shrink: 0; }
.icon-btn:active { background: var(--surface-2); }
.icon-spacer { width: 36px; flex-shrink: 0; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.card h3 { font-size: 16px; font-weight: 900; margin-bottom: 10px; }
.pill { font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); margin-left: 8px; vertical-align: middle; }
.tag { font-size: 11px; font-weight: 800; padding: 1px 7px; border-radius: 99px; background: var(--surface-2); color: var(--accent); }

.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field > span { font-weight: 800; font-size: 13px; color: var(--muted); }
.field input, .field select {
  width: 100%; padding: 11px 12px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--bg); outline: none;
}
.field input:focus, .field select:focus { border-color: var(--accent); }
.form-error { color: var(--danger); margin: 0; font-weight: 700; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 700; font-size: 14px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); flex-shrink: 0; }

.pick-grid { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pick { width: 42px; height: 42px; border-radius: 12px; border: 2px solid transparent; background: var(--surface-2); font-size: 21px; display: grid; place-items: center; padding: 0; }
.pick.on { border-color: var(--accent); background: var(--surface); }
.pick.num { width: auto; min-width: 42px; padding: 0 10px; font-size: 15px; font-weight: 800; }
.pick.swatch { background: var(--c); border-color: transparent; }
.pick.swatch.on { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--c); }
.pick-grid .emoji-input, .pick-grid .num-input { width: 70px; height: 42px; padding: 0 8px; text-align: center; border-radius: 12px; border: 1px solid var(--border); background: var(--bg); }
.row-btns { display: flex; gap: 10px; }
.row-btns .btn { flex: 1; }

/* ---------- belépés */
.auth { min-height: 100dvh; padding: 32px 16px; display: flex; flex-direction: column; justify-content: center; gap: 8px; text-align: center; }
.auth h1 { font-size: 30px; font-weight: 900; }
.auth .card { text-align: left; margin-top: 16px; }
.auth-logo { font-size: 56px; }
.demo-btns { display: flex; gap: 10px; margin-top: 12px; }
.demo-btns .btn { flex: 1; }

/* ---------- váz */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
}
.brand { font-weight: 900; font-size: 20px; display: flex; align-items: center; gap: 6px; }
.gear { font-size: 22px; width: 42px; height: 42px; border-radius: 50%; background: var(--surface); border: 1px solid var(--border); }
.gear.on { border-color: var(--accent); }
.avatar-btn { position: relative; width: 42px; height: 42px; border-radius: 50%; border: 3px solid var(--c); background: var(--surface); font-size: 22px; padding: 0; }
.avatar-btn .gear { position: absolute; right: -6px; bottom: -4px; font-size: 13px; background: var(--surface); border-radius: 50%; width: 20px; height: 20px; display: grid; place-items: center; box-shadow: var(--shadow); }
.view { padding: 4px 16px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom)); }
.view-title { font-size: 20px; font-weight: 900; margin: 6px 2px 14px; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; justify-content: center;
  background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  flex: 1; max-width: 140px; height: var(--nav-h);
  background: none; border: 0; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 12px; font-weight: 800;
}
.tabs .ti { font-size: 22px; filter: grayscale(1); opacity: .6; transition: transform .2s; }
.tabs button.on { color: var(--accent); }
.tabs button.on .ti { filter: none; opacity: 1; transform: translateY(-2px) scale(1.1); }

/* ---------- szint + napi cél */
.hero {
  border-radius: 22px; padding: 16px; margin-bottom: 14px; color: #fff;
  background: linear-gradient(135deg, #0f9d6e, #22c55e 60%, #a3e635);
  box-shadow: 0 10px 28px rgba(18, 155, 74, .35);
}
.hero-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.hello { font-size: 20px; font-weight: 900; }
.lvl { font-weight: 800; opacity: .9; font-size: 14px; }
.lvl-badge { width: 52px; height: 52px; border-radius: 16px; background: rgba(255, 255, 255, .22); display: grid; place-items: center; font-size: 26px; font-weight: 900; border: 2px solid rgba(255, 255, 255, .5); }
.xp { height: 10px; border-radius: 99px; background: rgba(255, 255, 255, .25); overflow: hidden; margin-top: 12px; }
.xp i { display: block; height: 100%; background: #fff; border-radius: 99px; transition: width .6s; }
.xp-lbl { font-size: 12px; font-weight: 700; opacity: .85; margin-top: 4px; }
.goal { display: flex; gap: 14px; align-items: center; margin-top: 14px; background: rgba(255, 255, 255, .14); border-radius: 16px; padding: 12px; }
.ring { --p: 0; width: 64px; height: 64px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center;
  background: conic-gradient(#fff calc(var(--p) * 360deg), rgba(255, 255, 255, .25) 0); }
.ring span { width: 50px; height: 50px; border-radius: 50%; background: #18a957; display: grid; place-items: center; font-weight: 900; font-size: 18px; }
.goal-title { font-weight: 900; }
.goal-sub { font-size: 13px; opacity: .95; }

.toolbar { display: flex; gap: 10px; margin-bottom: 8px; }
.toolbar .btn { flex: 1; }
.edit-hint { font-size: 13px; color: var(--muted); margin: 4px 2px 10px; }

/* ---------- feladat csempék */
.cat h2 { font-size: 14px; font-weight: 900; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 2px 10px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile {
  text-align: left; border: 1px solid var(--border); background: var(--surface);
  border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow);
  display: grid; gap: 6px; align-content: start; position: relative;
  transition: transform .12s;
}
.tile:active { transform: scale(.95); }
.tile.due { border-color: color-mix(in srgb, var(--due) 55%, var(--border)); }
.tile.due::after { content: ''; position: absolute; top: 10px; right: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--due); display: none; }
.tile.editing { border-style: dashed; border-color: var(--accent); }
.tile.editing .t-pts::after { content: ' ✏️'; }
.t-top { display: flex; justify-content: space-between; align-items: center; }
.t-emoji { font-size: 28px; line-height: 1; }
.t-pts { font-weight: 900; font-size: 13px; padding: 3px 8px; border-radius: 99px; background: var(--surface-2); color: var(--accent); }
.t-name { font-weight: 800; line-height: 1.2; }
.t-last { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.t-last i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); flex-shrink: 0; }
.tile.due .t-last { color: var(--due); font-weight: 700; }

.empty { text-align: center; display: grid; gap: 10px; justify-items: center; padding: 24px 16px; }
.empty p { margin: 0; }

/* ---------- ranglista */
.seg { display: flex; background: var(--surface-2); border-radius: 14px; padding: 4px; margin-bottom: 12px; gap: 4px; }
.seg button { flex: 1; border: 0; background: none; border-radius: 10px; padding: 8px 6px; font-weight: 800; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ---------- statisztika */
.catrow, .toprow { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.cr-name { width: 120px; flex-shrink: 0; font-weight: 800; font-size: 14px; }
.cr-bar { flex: 1; height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.cr-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 99px; }
.toprow { border-top: 1px solid var(--border); }
.toprow:first-of-type { border-top: 0; }
.tr-rank { width: 22px; color: var(--muted); font-weight: 900; }
.tr-name { flex: 1; font-weight: 800; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats3 { margin-bottom: 14px; }

.chart { display: flex; gap: 6px; height: 140px; align-items: stretch; }
.chart .col { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.chart .bars { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 3px; }
.chart { position: relative; }
.chart .bars i { width: 55%; max-width: 22px; background: color-mix(in srgb, var(--accent) 45%, var(--surface-2)); border-radius: 5px 5px 0 0; min-height: 2px; }
.chart .bars i.hit { background: var(--accent); }
.goal-line { position: absolute; left: 0; right: 0; bottom: calc(var(--goal) * (140px - 20px) / 140px + 20px); border-top: 2px dashed color-mix(in srgb, var(--accent) 60%, transparent); pointer-events: none; }
.goal-line span { position: absolute; right: 0; top: -18px; font-size: 11px; font-weight: 800; color: var(--accent); }
.chart span { font-size: 11px; text-align: center; color: var(--muted); font-weight: 700; }
.chart .today span { color: var(--accent); font-weight: 900; }

/* ---------- napló */
.day h3 { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; font-weight: 900; margin: 16px 2px 8px; text-transform: capitalize; }
.day-sum { font-size: 13px; text-transform: none; color: var(--muted); }
.day-sum.hit { color: var(--accent); }
.e-emoji { font-size: 24px; width: 34px; text-align: center; flex-shrink: 0; }
.list { padding: 4px 8px; }
.entry { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-top: 1px solid var(--border); }
.entry:first-child { border-top: 0; }
.e-main { flex: 1; min-width: 0; }
.e-name { font-weight: 800; }
.e-sub { font-size: 12px; color: var(--muted); }
.e-pts { font-weight: 900; color: var(--accent); }

/* ---------- kitűzők */
.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { text-align: center; padding: 12px 6px; }
.s-num { font-size: 18px; font-weight: 900; }
.s-lbl { font-size: 11px; color: var(--muted); font-weight: 700; }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.badge { margin: 0; text-align: center; display: grid; gap: 4px; justify-items: center; padding: 14px 10px; }
.badge .b-emoji { font-size: 34px; filter: grayscale(1); opacity: .35; }
.badge.got { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); background: linear-gradient(180deg, var(--surface-2), var(--surface)); }
.badge.got .b-emoji { filter: none; opacity: 1; }
.b-name { font-weight: 900; }
.b-desc { font-size: 12px; color: var(--muted); }
.b-prog { width: 100%; height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 4px; }
.b-prog i { display: block; height: 100%; background: var(--accent); }
.b-num { font-size: 11px; color: var(--muted); font-weight: 700; }

/* ---------- beállítások */
.row-btns.col { flex-direction: column; }
.welcome { text-align: center; display: grid; gap: 10px; }
.welcome .form { text-align: left; margin-top: 6px; }

/* ---------- modál */
.backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(10, 5, 30, .5); display: flex; align-items: flex-end; justify-content: center; animation: fade .2s; }
.sheet {
  position: relative; width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto;
  background: var(--surface); border-radius: 24px 24px 0 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  animation: up .25s cubic-bezier(.2, .9, .3, 1.2);
}
.sheet h2 { font-size: 20px; font-weight: 900; margin: 0 40px 12px 0; }
.sheet .close { position: absolute; top: 12px; right: 12px; }
.confirm-text { font-size: 16px; margin: 8px 40px 18px 0; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(100%); } }

.pop { text-align: center; display: grid; gap: 12px; }
.pop-level { font-size: 64px; font-weight: 900; color: var(--accent); line-height: 1; animation: pop .6s cubic-bezier(.2, .9, .3, 1.6); }
.pop-sub { font-weight: 800; font-size: 18px; }
.pop-title { font-size: 22px; font-weight: 900; }
.bp-item { display: flex; gap: 12px; align-items: center; text-align: left; background: var(--surface-2); border-radius: 14px; padding: 12px; }
.bp-item .b-emoji { font-size: 40px; animation: pop .6s cubic-bezier(.2, .9, .3, 1.6); }
@keyframes pop { from { transform: scale(0) rotate(-30deg); } }

/* ---------- toast */
#snack-root { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom)); z-index: 30; display: grid; justify-items: center; gap: 8px; padding: 0 16px; pointer-events: none; }
.snack {
  pointer-events: auto; max-width: 528px; width: 100%;
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  background: #12291c; color: #fff; padding: 12px 14px; border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .3); animation: up .25s ease-out;
}
.snack.out { opacity: 0; transform: translateY(10px); transition: .25s; }
.snack-btn { background: none; border: 0; color: #86efac; font-weight: 900; padding: 4px 6px; white-space: nowrap; }

/* ---------- effektek */
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.float-pts { position: absolute; transform: translate(-50%, -50%); font-size: 28px; font-weight: 900; color: var(--accent); text-shadow: 0 2px 0 var(--surface); animation: floatUp 1.1s ease-out forwards; }
@keyframes floatUp { to { transform: translate(-50%, -150%) scale(1.3); opacity: 0; } }
.confetti { position: absolute; width: 8px; height: 12px; border-radius: 2px; animation: confetti .9s ease-out forwards; }
@keyframes confetti { to { transform: translate(var(--dx), var(--dy)) rotate(var(--r)); opacity: 0; } }

/* ---------- betöltőképernyő: alvó cica felébred */
#splash {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-content: center; justify-items: center; gap: 14px;
  background: linear-gradient(160deg, #0f9d6e, #22c55e 60%, #a3e635);
  color: #fff; transition: opacity .45s;
}
#splash.out { opacity: 0; pointer-events: none; }
.kitty { width: 230px; height: auto; overflow: visible; }
.kitty .fur { fill: #f0892a; }
.kitty .stripe { fill: none; stroke: #c45f0c; stroke-width: 4; stroke-linecap: round; }
.kitty .tail path { fill: none; stroke: #f0892a; stroke-width: 13; stroke-linecap: round; }
.kitty .pink { fill: #ff9fb8; opacity: .8; }
.kitty .blush { fill: #ff7aa2; opacity: .35; }
.kitty .eyes-closed path { fill: none; stroke: #6e3508; stroke-width: 3.5; stroke-linecap: round; }
.kitty .iris { fill: #9be86e; }
.kitty .pupil { fill: #15131d; }
.kitty .nose { fill: #ff8fab; }
.kitty .line, .kitty .line path { fill: none; stroke: #7a3e0c; stroke-width: 2; stroke-linecap: round; }
.kitty .paw { fill: #ffe1bf; }
.kitty .shadow { fill: rgba(0, 0, 0, .18); }
.kitty .zzz text { fill: #fff; font: 900 17px Nunito, sans-serif; opacity: 0; animation: cat-z 1.2s ease-out infinite; }
.kitty .zzz text:nth-child(2) { animation-delay: .3s; }
.kitty .zzz text:nth-child(3) { animation-delay: .6s; }
.kitty .zzz { animation: cat-hide .2s 1.3s forwards; }

/* alvás: lehajtott fej, szuszogás */
.kitty .head { transform-origin: 110px 132px; transform: translateY(8px) rotate(-7deg); animation: cat-head .55s 1.3s cubic-bezier(.3, 1.6, .5, 1) forwards; }
.kitty .body { transform-origin: 110px 170px; animation: cat-breathe 1.3s ease-in-out; }
/* ébredés: szemnyitás, pislogás, fülrezdülés, farokcsóválás, szívecske */
.kitty .eyes-closed { animation: cat-hide 0s 1.4s forwards; }
.kitty .eyes-open { opacity: 0; animation: cat-show 0s 1.4s forwards; }
.kitty .eye { transform-box: fill-box; transform-origin: center; animation: cat-open .3s 1.4s both, cat-blink .22s 2.15s; }
.kitty .ear-r { transform-origin: 130px 72px; animation: cat-twitch-r .3s 1.9s; }
.kitty .ear-l { transform-origin: 90px 72px; animation: cat-twitch-l .3s 2.35s; }
.kitty .tail { transform-origin: 166px 150px; animation: cat-tail .6s 1.5s ease-in-out infinite alternate; }
.kitty .heart { fill: #fff; font: 900 24px sans-serif; opacity: 0; transform-box: fill-box; transform-origin: center; animation: cat-heart .7s 2.1s forwards; }

@keyframes cat-z { 0% { opacity: 0; transform: translate(0, 6px); } 30% { opacity: 1; } 100% { opacity: 0; transform: translate(7px, -10px); } }
@keyframes cat-head { to { transform: none; } }
@keyframes cat-breathe { 50% { transform: scale(1.03, 1.06); } }
@keyframes cat-hide { to { opacity: 0; } }
@keyframes cat-show { to { opacity: 1; } }
@keyframes cat-open { from { transform: scaleY(.15); } }
@keyframes cat-blink { 50% { transform: scaleY(.1); } }
@keyframes cat-twitch-r { 50% { transform: rotate(14deg); } }
@keyframes cat-twitch-l { 50% { transform: rotate(-14deg); } }
@keyframes cat-tail { from { transform: rotate(-5deg); } to { transform: rotate(12deg); } }
@keyframes cat-heart { 0% { opacity: 0; transform: scale(0) translateY(8px); } 60% { opacity: 1; transform: scale(1.25); } 100% { opacity: 1; transform: scale(1) translateY(-4px); } }

.splash-title { font-weight: 900; font-size: 30px; letter-spacing: .01em; }
.splash-bar { width: 200px; height: 8px; border-radius: 99px; background: rgba(255, 255, 255, .25); overflow: hidden; }
.splash-bar i { display: block; height: 100%; width: 0; background: #fff; border-radius: 99px; animation: splash-bar 2.6s cubic-bezier(.4, .1, .3, 1) forwards; }
@keyframes splash-bar { to { width: 100%; } }
.splash-sub { display: grid; font-size: 14px; font-weight: 700; opacity: .9; }
.splash-sub span { grid-area: 1 / 1; text-align: center; }
.splash-sub span:first-child { animation: cat-hide .2s 1.4s forwards; }
.splash-sub span:last-child { opacity: 0; animation: cat-show .3s 1.5s forwards; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
