@font-face {
  font-family: 'Pixelify';
  src: url(../assets/fonts/pixelify.woff2) format('woff2');
  font-weight: 400 700;
  font-display: block;
}
:root {
  --plum: #3a1635;
  --ink: #3a1635;
  --paper: #fffaf3;
  --pink: #ef5d78;
  --pink-soft: #f9bac4;
  --ice: #d9f1ff;
  --sky: #7cc6f1;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #1d2346; overflow: hidden; overscroll-behavior: none; }
body { font-variant-ligatures: none; font-feature-settings: 'liga' 0, 'clig' 0, 'calt' 0; letter-spacing: .02em; font-family: 'Pixelify', system-ui, sans-serif; color: var(--ink); -webkit-user-select: none; user-select: none; touch-action: none; }
#app { position: relative; width: 100%; max-width: 480px; height: 100%; margin: 0 auto; overflow: hidden; background: var(--sky); }
#world { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; cursor: none; }

#hud { position: absolute; top: calc(var(--safe-t) + 10px); left: 10px; display: flex; gap: 8px; pointer-events: none; }
.pill {
  display: flex; align-items: center; gap: 6px; padding: 4px 12px 4px 6px; border-radius: 999px;
  background: var(--paper); border: 3px solid var(--plum); box-shadow: 0 3px 0 var(--plum);
  font-size: 20px; font-weight: 700; line-height: 1; min-width: 64px;
}
.pill.bump { animation: bump .35s cubic-bezier(.3, 1.8, .5, 1); }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.22); } 100% { transform: scale(1); } }
.icon { width: 24px; height: 24px; image-rendering: pixelated; }

#toast {
  position: absolute; left: 50%; top: calc(var(--safe-t) + 62px); transform: translate(-50%, -20px) scale(.9);
  width: max-content; max-width: calc(100% - 24px); text-align: center; line-height: 1.25;
  background: var(--paper); border: 3px solid var(--plum); border-radius: 16px; box-shadow: 0 3px 0 var(--plum);
  padding: 8px 16px; font-size: 18px; opacity: 0; pointer-events: none; z-index: 40;
  transition: opacity .25s, transform .35s cubic-bezier(.3, 1.6, .5, 1);
}
#toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }

.sheet { position: absolute; inset: 0; display: flex; align-items: flex-end; justify-content: center; background: rgba(40, 20, 50, .35); padding: 16px 16px calc(var(--safe-b) + 16px); }
.sheet[hidden] { display: none; }
.sheet .card {
  width: 100%; background: var(--paper); border: 4px solid var(--plum); border-radius: 24px; box-shadow: 0 6px 0 var(--plum);
  padding: 18px 18px 20px; text-align: center; animation: pop-up .4s cubic-bezier(.3, 1.5, .5, 1);
}
@keyframes pop-up { from { transform: translateY(60px) scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }
#sheet-portrait { width: 108px; height: 108px; image-rendering: pixelated; margin: -70px auto 0; display: block; background: var(--ice); border: 4px solid var(--plum); border-radius: 50%; }
.card h2 { margin: 10px 0 2px; font-size: 26px; }
.card p { margin: 0 0 12px; font-size: 16px; opacity: .8; }
#name-input {
  width: 100%; font: inherit; font-size: 24px; text-align: center; padding: 10px; border-radius: 14px;
  border: 3px solid var(--plum); background: #fff; color: var(--ink); outline: none; -webkit-user-select: text; user-select: text;
}
#name-input:focus { border-color: var(--pink); }
.chips { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 12px 0; }
.chip { font: inherit; font-size: 18px; padding: 8px 14px; border-radius: 999px; border: 3px solid var(--plum); background: var(--ice); color: var(--ink); min-height: 44px; }
.chip:active, .btn:active { transform: translateY(2px); }
.row { display: flex; gap: 10px; }
.btn {
  flex: 1; font: inherit; font-size: 22px; font-weight: 700; min-height: 56px; border-radius: 16px; border: 3px solid var(--plum);
  background: var(--pink); color: #fff; box-shadow: 0 4px 0 var(--plum); text-shadow: 0 2px 0 rgba(58, 22, 53, .35);
}
.btn.ghost { flex: 0 0 64px; background: var(--paper); color: var(--ink); text-shadow: none; }

#title { position: absolute; inset: 0; z-index: 10; background: #8b8dc9; display: flex; flex-direction: column; align-items: center; transition: opacity .6s, transform .6s; }
#title.gone { opacity: 0; transform: scale(1.08); pointer-events: none; }
.title-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; }
.logo { position: relative; width: 78%; margin-top: calc(var(--safe-t) + 7vh); image-rendering: pixelated; animation: float 3s ease-in-out infinite; filter: drop-shadow(0 4px 0 rgba(58, 22, 53, .3)); }
@keyframes float { 50% { transform: translateY(-8px) rotate(-1deg); } }
.tap-hint {
  position: absolute; bottom: calc(var(--safe-b) + 8vh); font-size: 24px; color: #fff; padding: 10px 22px; border-radius: 999px;
  background: rgba(58, 22, 53, .55); border: 3px solid #fff; animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 50% { transform: scale(1.07); } }

/* ---------- HUD buttons ---------- */
.btn-pill { font: inherit; color: inherit; pointer-events: auto; cursor: pointer; }
.btn-pill.active { background: #ffe27a; transform: scale(1.08); }
.btn-pill.empty { opacity: .75; }
#hud { pointer-events: none; }
#hud .btn-pill { pointer-events: auto; }
#hud-right { position: absolute; top: calc(var(--safe-t) + 10px); right: 10px; display: flex; gap: 8px; }
.round {
  width: 48px; height: 48px; border-radius: 50%; border: 3px solid var(--plum); background: var(--paper);
  box-shadow: 0 3px 0 var(--plum); display: grid; place-items: center; padding: 0; cursor: pointer;
}
.round:active, .btn-pill:active { transform: translateY(2px); }
.round.off { opacity: .5; }
.round .badge { position: absolute; }
#feed-hint {
  position: absolute; left: 50%; bottom: calc(var(--safe-b) + 18px); transform: translateX(-50%); white-space: nowrap;
  background: var(--paper); border: 3px solid var(--plum); border-radius: 999px; box-shadow: 0 3px 0 var(--plum);
  padding: 6px 6px 6px 16px; font-size: 17px; display: flex; align-items: center; gap: 10px;
}
#feed-hint[hidden] { display: none; }
#feed-hint button { font: inherit; font-size: 16px; border: 3px solid var(--plum); border-radius: 999px; background: var(--pink); color: #fff; padding: 6px 14px; }
.px-icon { image-rendering: pixelated; vertical-align: middle; }

/* ---------- Journal ---------- */
.journal-card { max-height: 78vh; display: flex; flex-direction: column; padding: 12px; text-align: left; }
.journal-head { position: relative; display: flex; flex: 0 0 auto; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 8px; padding: 2px 52px 4px 2px; }
.journal-head::-webkit-scrollbar { display: none; }
.journal-head .tab, .journal-head .close { flex: 0 0 auto; }
.tab { font: inherit; font-size: 16px; padding: 7px 12px; border-radius: 999px; border: 3px solid var(--plum); background: var(--paper); color: var(--ink); }
.tab.on { background: var(--pink); color: #fff; }
.journal-head .close { position: absolute; top: 0; right: 0; }
.close { font: inherit; font-size: 20px; width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--plum); background: var(--paper); color: var(--ink); }
#journal-list { overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; padding: 2px; }
.friend { display: flex; gap: 10px; padding: 10px; border: 3px solid var(--plum); border-radius: 16px; background: #fff; margin-bottom: 8px; }
.friend-pic { flex: 0 0 64px; height: 64px; border-radius: 12px; background: var(--ice); display: grid; place-items: center; overflow: hidden; }
.friend-pic canvas { width: 56px; height: 56px; image-rendering: pixelated; }
.friend-info { flex: 1; min-width: 0; }
.friend-name { font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tag { font-size: 13px; font-weight: 400; background: #ffe27a; border: 2px solid var(--plum); border-radius: 999px; padding: 1px 8px; }
.friend-hearts { display: flex; gap: 2px; margin: 3px 0; }
.friend-hearts .dim { opacity: .2; filter: grayscale(1); }
.friend-traits { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 4px; }
.trait { font-size: 13px; background: var(--ice); border-radius: 999px; padding: 1px 8px; }
.friend-status { display: flex; gap: 6px; flex-wrap: wrap; }
.status { font-size: 14px; display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; background: #f2f0f7; }
.status.want { background: #ffe0e6; }
.status.ok { background: #e3f6ea; }
.grow-label { font-size: 13px; margin-top: 4px; opacity: .8; }
.grow { height: 10px; border: 2px solid var(--plum); border-radius: 999px; background: #fff; overflow: hidden; }
.grow-fill { height: 100%; background: linear-gradient(90deg, #8fe0b0, #ffe27a); }
.day { font-size: 16px; margin: 12px 4px 4px; opacity: .7; }
.entry { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: #fff; border-radius: 12px; margin-bottom: 4px; font-size: 16px; }
.entry-text { flex: 1; }
.entry-time { font-size: 12px; opacity: .55; }
.empty { text-align: center; opacity: .7; padding: 20px; }
#welcome-lines { text-align: left; margin: 10px 0 14px; }
.wl { display: flex; align-items: center; gap: 10px; font-size: 18px; padding: 6px 4px; }
.next-heart { height: 6px; width: 60%; background: #f6e3ea; border-radius: 999px; overflow: hidden; margin: 0 0 5px; }
.next-fill { height: 100%; background: var(--pink); }
.entry.findable { cursor: pointer; box-shadow: inset 0 0 0 2px #f9bac4; }
.entry.findable::after { content: "›"; font-size: 20px; opacity: .5; }
.friend { cursor: pointer; }

/* ---------- Play hub ---------- */
.round.play { background: #ffe27a; }
.round.play.ping::after { content: ""; position: absolute; width: 12px; height: 12px; border-radius: 50%; background: var(--pink); border: 2px solid var(--plum); transform: translate(16px, -16px); }
.hub-card h2 { margin: 0 0 12px; }
.hub-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.hub-tile {
  font: inherit; color: var(--ink); background: #fff; border: 3px solid var(--plum); border-radius: 18px; box-shadow: 0 4px 0 var(--plum);
  padding: 12px 8px 10px; display: flex; flex-direction: column; align-items: center; gap: 6px; min-height: 118px; cursor: pointer;
}
.hub-tile:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--plum); }
.hub-tile .t-name { font-size: 19px; font-weight: 700; }
.hub-tile .t-sub { font-size: 13px; opacity: .75; text-align: center; line-height: 1.2; }
.hub-tile.done { opacity: .5; box-shadow: 0 2px 0 var(--plum); }
.hub-tile .dots { display: flex; gap: 4px; }
.hub-tile .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--pink); border: 2px solid var(--plum); }
.hub-tile .dot.used { background: #eee; }
.btn.wide { flex: 1; }
#hub-progress { font-size: 15px; margin: 0 2px 12px; text-align: left; }
#hub-progress span { display: block; margin-bottom: 4px; }

/* feeding: pick which fish to give */
#feed-hint { flex-direction: column; align-items: stretch; border-radius: 22px; padding: 6px 8px 8px 14px; white-space: normal; max-width: calc(100% - 20px); }
.feed-top { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
#feed-kinds { display: flex; gap: 6px; overflow-x: auto; padding-top: 6px; scrollbar-width: none; }
.fk { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 50px; padding: 4px 6px; border: 3px solid var(--plum);
  border-radius: 12px; background: #fff; font: inherit; font-size: 12px; color: var(--ink); cursor: pointer; }
.fk.on { background: #ffe27a; box-shadow: 0 3px 0 var(--plum); }
.fk .n { font-weight: 700; font-size: 13px; }
.fk canvas { image-rendering: pixelated; }
