/* Drop your font into assets/font/ as app.woff2 (or app.ttf) — it is picked up automatically. */
@font-face { font-family: "AppFont"; src: url(assets/font/app.woff2) format("woff2"), url(assets/font/app.ttf) format("truetype"); font-display: swap; }

:root {
  --sky: #c7b6f5;
  --sky-dot: #b7a3ee;
  --ink: #3b1f4a;
  --paper: #fff5fa;
  --paper-2: #f6e3f0;
  --heart: #ff4f79;
  --heart-dk: #c7325a;
  --gold: #ffc93c;
  --gold-dk: #c98a12;
  --mint: #4fd6a0;
  --mint-dk: #23966a;
  --muted: #8a6f96;
  --px: 3px;
  --font: "AppFont", "Noto Sans Georgian", "BPG Arial", "Sylfaen", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); color: var(--ink); font-size: 16px; line-height: 1.35;
  background-color: var(--sky);
  background-image: radial-gradient(var(--sky-dot) 1.5px, transparent 1.6px);
  background-size: 12px 12px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px dashed var(--heart); outline-offset: 2px; }

#app { max-width: 520px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }

/* ---------- pixel window ---------- */
.win {
  background: var(--paper); border: var(--px) solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  clip-path: polygon(0 6px, 6px 6px, 6px 0, calc(100% - 6px) 0, calc(100% - 6px) 6px, 100% 6px, 100% calc(100% - 6px), calc(100% - 6px) calc(100% - 6px), calc(100% - 6px) 100%, 6px 100%, 6px calc(100% - 6px), 0 calc(100% - 6px));
}
/* clip-path hides the drop shadow, so windows that need it use a wrapper filter */
.shadow { filter: drop-shadow(4px 4px 0 var(--ink)); }
.shadow > .win { box-shadow: none; }

/* ---------- icons ---------- */
.ico { display: inline-block; flex: none; image-rendering: pixelated; image-rendering: crisp-edges; background-repeat: no-repeat; vertical-align: middle; }

/* ---------- buttons ---------- */
.btn {
  border: var(--px) solid var(--ink); background: var(--heart); color: #fff;
  padding: 9px 14px; font-weight: 700; font-size: 14px; line-height: 1;
  box-shadow: 0 4px 0 var(--heart-dk), 0 4px 0 var(--px) var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px;
  transition: transform .05s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--heart-dk), 0 1px 0 var(--px) var(--ink); }
.btn.gold { background: var(--gold); color: var(--ink); box-shadow: 0 4px 0 var(--gold-dk), 0 4px 0 var(--px) var(--ink); }
.btn.mint { background: var(--mint); color: var(--ink); box-shadow: 0 4px 0 var(--mint-dk), 0 4px 0 var(--px) var(--ink); }
.btn.ghost { background: var(--paper); color: var(--ink); box-shadow: 0 4px 0 var(--paper-2), 0 4px 0 var(--px) var(--ink); }
.btn.sq { width: 44px; height: 44px; padding: 0; min-height: 0; }
.btn.wide { width: 100%; min-height: 48px; font-size: 16px; }
.btn[disabled] { filter: grayscale(.8); opacity: .55; pointer-events: none; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 6px; font-size: 13px; }

input.field {
  width: 100%; border: var(--px) solid var(--ink); background: #fff; padding: 11px 12px; font-size: 16px; border-radius: 0;
  box-shadow: inset 3px 3px 0 var(--paper-2);
}
input.field:focus { outline: none; box-shadow: inset 3px 3px 0 var(--paper-2), 0 0 0 3px var(--heart); }
.code-input { text-align: center; font-size: 28px !important; letter-spacing: 10px; font-weight: 700; }

/* ---------- HUD ---------- */
.hud { position: sticky; top: 0; z-index: 20; padding: 10px 10px 8px; }
.hud .win { display: flex; align-items: center; gap: 8px; padding: 8px 10px; }
.duo { display: flex; align-items: center; flex: none; }
.duo .av { width: 58px; height: 58px; background: var(--paper-2); border: var(--px) solid var(--ink); display: grid; place-items: center; }
.duo .av + .heartlink + .av { margin-left: 0; }
.heartlink { margin: 0 -4px; z-index: 1; animation: beat 1.6s steps(2) infinite; }
@keyframes beat { 50% { transform: scale(1.18); } }
.stats { flex: 1; min-width: 0; }
.stats .row { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-weight: 700; font-size: 13px; }
.lvl { background: var(--ink); color: var(--gold); padding: 1px 6px; font-size: 12px; }
.xpbar { display: flex; gap: 2px; margin-top: 5px; height: 10px; }
.xpbar i { flex: 1; background: var(--paper-2); border: 2px solid var(--ink); }
.xpbar i.on { background: var(--mint); }
.xptext { font-size: 11px; color: var(--muted); margin-top: 2px; }
.coins { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; }
.bell { position: relative; background: none; border: 0; padding: 4px; }
.badge { position: absolute; top: -2px; right: -4px; background: var(--heart); color: #fff; font-size: 11px; font-weight: 700; min-width: 18px; height: 18px; padding: 0 4px; border: 2px solid var(--ink); display: grid; place-items: center; line-height: 1; }

/* ---------- main ---------- */
main { flex: 1; padding: 4px 10px 110px; }
.seg { display: flex; gap: 6px; margin: 4px 0 12px; }
.seg button { flex: 1; border: var(--px) solid var(--ink); background: var(--paper-2); padding: 8px 6px; font-weight: 700; font-size: 14px; position: relative; color: var(--muted); }
.seg button.on { background: var(--ink); color: var(--paper); }
.seg .badge { top: -9px; right: -6px; }

.list { display: flex; flex-direction: column; gap: 10px; }
.row-card { display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 8px; }
.row-card .tile { width: 60px; height: 60px; background: var(--paper-2); display: grid; place-items: center; flex: none; border: 2px solid var(--ink); }
.row-card .body { flex: 1; min-width: 0; }
.row-card .title { font-weight: 700; font-size: 15px; overflow-wrap: anywhere; }
.row-card .meta { display: flex; gap: 10px; margin-top: 4px; font-size: 13px; font-weight: 700; flex-wrap: wrap; align-items: center; }
.row-card .acts { display: flex; gap: 6px; flex: none; }
.row-card.done { opacity: .55; }
.row-card.pending .tile { background: #fff1c2; }
.tag { display: inline-flex; align-items: center; gap: 3px; }
.t-coin { color: var(--gold-dk); } .t-xp { color: var(--mint-dk); } .t-mute { color: var(--muted); font-weight: 400; }
.pill { font-size: 11px; font-weight: 700; padding: 2px 6px; border: 2px solid var(--ink); background: var(--gold); }
.pill.wait { background: #fff1c2; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.item { padding: 12px 10px 10px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; position: relative; height: 100%; }
.item .title { font-weight: 700; font-size: 14px; min-height: 2.7em; display: flex; align-items: center; overflow-wrap: anywhere; }
.item .btn { width: 100%; margin-top: auto; }
.item.locked .ico { filter: grayscale(1) brightness(.6); }
.item .lockbadge { position: absolute; top: 8px; right: 8px; background: var(--ink); color: var(--gold); font-size: 11px; font-weight: 700; padding: 2px 5px; display: flex; align-items: center; gap: 2px; }
.item .stock { position: absolute; top: 8px; left: 8px; font-size: 11px; color: var(--muted); font-weight: 700; }
.item.used { opacity: .5; }

.empty { text-align: center; padding: 28px 16px; }
.empty p { margin: 10px 0 14px; color: var(--muted); }

.fab { position: fixed; z-index: 25; right: max(16px, calc(50% - 244px)); bottom: 92px; width: 60px; height: 60px; font-size: 30px; }

.oldtoggle { display: flex; align-items: center; gap: 8px; width: 100%; margin: 18px 0 10px; background: none; border: 0; border-top: var(--px) dashed var(--ink); padding: 12px 2px 4px; font-weight: 700; font-size: 14px; color: var(--ink); text-align: left; }
.oldtoggle span { background: var(--ink); color: var(--paper); font-size: 11px; padding: 1px 6px; }
.oldlist { opacity: .9; }

/* ---------- bottom nav ---------- */
nav.tabs { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; padding: 0 10px calc(10px + env(safe-area-inset-bottom)); max-width: 520px; margin: 0 auto; }
nav.tabs .win { display: flex; padding: 4px; }
nav.tabs button { flex: 1; border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: 11px; font-weight: 700; padding: 5px 0 4px; color: var(--muted); position: relative; }
nav.tabs button.on { background: var(--paper-2); color: var(--ink); }
nav.tabs .badge { top: 0; right: calc(50% - 26px); }

/* ---------- modal / sheet ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(59, 31, 74, .55); display: flex; align-items: flex-end; justify-content: center; animation: fade .12s; }
@keyframes fade { from { opacity: 0; } }
.sheet { width: 100%; max-width: 520px; max-height: 92vh; display: flex; flex-direction: column; padding: 0 8px 8px; animation: rise .16s steps(4); }
@keyframes rise { from { transform: translateY(40px); } }
.sheet > .win { display: flex; flex-direction: column; min-height: 0; max-height: calc(92vh - 8px); }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 10px 10px 8px 14px; border-bottom: var(--px) solid var(--ink); background: var(--paper-2); }
.sheet-head h3 { margin: 0; flex: 1; font-size: 16px; }
.sheet-body { padding: 14px; overflow-y: auto; }
.x { background: none; border: 0; font-size: 22px; font-weight: 700; width: 36px; height: 36px; line-height: 1; }

.form-row { margin-bottom: 14px; }
.form-row > label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 5px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.icon-pick { display: flex; align-items: center; gap: 12px; }
.icon-pick .tile { width: 84px; height: 84px; border: var(--px) solid var(--ink); background: var(--paper-2); display: grid; place-items: center; }
.stepper { display: flex; align-items: stretch; border: var(--px) solid var(--ink); background: #fff; }
.stepper button { width: 40px; border: 0; background: var(--paper-2); font-size: 20px; font-weight: 700; }
.stepper input { width: 100%; min-width: 0; border: 0; text-align: center; font-weight: 700; font-size: 17px; padding: 8px 0; background: transparent; }
.stepper .ico { align-self: center; margin-left: 6px; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 14px; }
.check input { appearance: none; width: 26px; height: 26px; border: var(--px) solid var(--ink); background: #fff; margin: 0; display: grid; place-items: center; }
.check input:checked { background: var(--mint); }
.check input:checked::after { content: ""; width: 10px; height: 10px; background: var(--ink); }
.row-btns { display: flex; gap: 10px; margin-top: 18px; }
.row-btns .btn { flex: 1; }

/* picker */
.picker-cats { display: flex; gap: 4px; overflow-x: auto; padding: 8px 10px; border-bottom: var(--px) solid var(--ink); scrollbar-width: none; flex: none; }
.picker-cats button { flex: none; border: 2px solid transparent; background: none; padding: 3px; }
.picker-cats button.on { border-color: var(--ink); background: var(--paper-2); }
.picker-search { padding: 8px 10px 0; flex: none; }
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 4px; padding: 10px; overflow-y: auto; min-height: 50vh; align-content: start; }
.picker-grid button { border: 2px solid transparent; background: none; height: 56px; display: grid; place-items: center; padding: 0; content-visibility: auto; contain-intrinsic-size: 56px; }
.picker-grid button:hover, .picker-grid button.on { border-color: var(--ink); background: var(--paper-2); }

/* events */
.ev { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 2px dashed var(--paper-2); font-size: 14px; }
.ev.new { font-weight: 700; }
.ev time { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }

/* ---------- auth / onboarding ---------- */
.center { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 24px 18px; gap: 18px; }
.logo { text-align: center; }
.logo .pair { display: flex; justify-content: center; align-items: flex-end; gap: 0; }
.logo h1 { font-size: 26px; margin: 10px 0 0; }
.card { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.card h2 { margin: 0; font-size: 18px; }
.hint { font-size: 13px; color: var(--muted); margin: 0; }
.bigcode { font-size: 34px; font-weight: 700; letter-spacing: 8px; text-align: center; padding: 10px; background: var(--paper-2); border: var(--px) dashed var(--ink); user-select: all; }
.or { text-align: center; color: var(--muted); font-size: 13px; }

/* profile */
.prof { padding: 18px; text-align: center; }
.prof .tile { width: 108px; height: 108px; margin: 0 auto 10px; border: var(--px) solid var(--ink); background: var(--paper-2); display: grid; place-items: center; }
.prof h2 { margin: 0 0 4px; }
.statgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.statgrid div { background: var(--paper-2); border: 2px solid var(--ink); padding: 8px 4px; font-weight: 700; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 18px; }
.statgrid small { font-size: 11px; color: var(--muted); }
.section { margin-top: 14px; padding: 14px; }
.section h3 { margin: 0 0 10px; font-size: 15px; }

/* ---------- toast & reward ---------- */
#toast { position: fixed; z-index: 90; left: 50%; top: 14px; transform: translateX(-50%); width: calc(100% - 24px); max-width: 480px; pointer-events: none; display: flex; flex-direction: column; gap: 6px; }
.toast { display: flex; gap: 8px; align-items: center; padding: 8px 12px; font-weight: 700; font-size: 14px; animation: drop .2s steps(3); }
.toast.err { background: #ffe0e6; }
@keyframes drop { from { transform: translateY(-20px); opacity: 0; } }

.levelup { position: fixed; inset: 0; z-index: 95; display: grid; place-items: center; background: rgba(59, 31, 74, .7); }
.levelup .win { padding: 26px 30px; text-align: center; animation: pop .5s steps(5); }
.levelup b { display: block; font-size: 44px; color: var(--heart); margin: 6px 0; }
@keyframes pop { 0% { transform: scale(.3); } 70% { transform: scale(1.1); } }
.spark { position: absolute; animation: spark 1.2s steps(6) forwards; }
@keyframes spark { to { transform: translate(var(--dx), var(--dy)); opacity: 0; } }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media (min-width: 560px) { main { padding-top: 8px; } }
