:root {
  --bg: #f2efe8; --ink: #4a4240; --soft: rgba(74, 66, 64, .5); --faint: rgba(74, 66, 64, .08); --line: rgba(74, 66, 64, .14);
  --card: #fffdf9; --shadow: rgba(60, 40, 20, .12); --accent: #e0897a; --gold: #d9a441; --s: 4;
  --food: #8fb3cf; --energy: #b6a6dc; --mood: #ef8fa2;
}
:root[data-theme="dark"] {
  --bg: #1f2232; --ink: #e7e2ee; --soft: rgba(231, 226, 238, .55); --faint: rgba(231, 226, 238, .08); --line: rgba(231, 226, 238, .16);
  --card: #2a2e42; --shadow: rgba(0, 0, 0, .3);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 14px/1.45 "M PLUS Rounded 1c", ui-rounded, "Segoe UI", "Hiragino Sans", system-ui, sans-serif;
  overflow: hidden; user-select: none; -webkit-user-select: none; touch-action: none;
}
body.ready { transition: background-color .4s, color .4s; }
button { font: inherit; color: inherit; }
a { color: inherit; }
svg.px { display: block; shape-rendering: crispEdges; overflow: visible; }
img.px { display: block; image-rendering: pixelated; pointer-events: none; }
.coin { display: inline-block; vertical-align: -2px; }

/* ---- buttons ---- */
.btn {
  border: 1px solid var(--line); background: transparent; border-radius: 99px; padding: 8px 16px; cursor: pointer;
  font-size: 13px; transition: background .2s, border-color .2s, opacity .2s; display: inline-flex; align-items: center; gap: 8px; justify-content: center;
}
.btn:hover { background: var(--faint); }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.primary:hover { opacity: .88; }
.btn.block { width: 100%; }
.btn.danger { color: #c4574a; border-color: rgba(196, 87, 74, .35); }
.btn:disabled { opacity: .45; cursor: default; }
.link { background: none; border: 0; padding: 0; cursor: pointer; color: var(--soft); text-decoration: underline; text-underline-offset: 3px; font-size: 12px; }

/* ---- the room ---- */
#room {
  position: fixed; inset: 0;
  background: var(--bg) url(../items/floor-planks-light.png) repeat; background-size: 64px 96px; image-rendering: pixelated;
}
:root[data-theme="dark"] #room { background-image: url(../items/floor-planks-dark.png); }
.thing { position: absolute; left: 0; top: 0; will-change: transform; }
.item { cursor: pointer; touch-action: none; }
.item::after {
  content: ''; position: absolute; left: 50%; bottom: calc(-1px * var(--s)); transform: translateX(-50%);
  width: 86%; height: calc(3px * var(--s)); background: var(--shadow); border-radius: 50%; z-index: -1;
}
.item.flat::after { display: none; }
.item.dragging { cursor: grabbing; filter: drop-shadow(0 6px 6px rgba(0, 0, 0, .15)); }
.item.shake { animation: shake .12s steps(2) 4; }
.item img { transform-origin: 50% 100%; transition: transform .25s cubic-bezier(.3, 1.6, .5, 1); }
.item.over img { transform: rotate(18deg); }
.item.pop { animation: pop .3s ease-out; }
@keyframes shake { 50% { margin-left: calc(1px * var(--s)); } }
@keyframes pop { from { opacity: 0; margin-top: -10px; } }
:root[data-theme="dark"] .item img, :root[data-theme="dark"] #toy, :root[data-theme="dark"] .treat,
:root[data-theme="dark"] .gift { filter: brightness(.72) saturate(.85); }
.fish { position: absolute; left: 0; top: 0; pointer-events: none; }
.item-front { pointer-events: none; }
.item-front.shake { animation: shake .12s steps(2) 4; }
:root[data-theme="dark"] .item-front img { filter: brightness(.72) saturate(.85); }

#pet { width: calc(26px * var(--s)); height: calc(20px * var(--s)); cursor: grab; touch-action: none; }
#pet::after {
  content: ''; position: absolute; left: 50%; bottom: calc(-1.5px * var(--s));
  width: calc(18px * var(--s)); height: calc(3px * var(--s)); transform: translateX(-50%);
  background: var(--shadow); border-radius: 50%; z-index: -1; transition: opacity .2s;
}
#pet.carried { cursor: grabbing; }
#pet.noshadow::after { opacity: 0; }
#pet.inbox { pointer-events: none; }
#pet .spr {
  position: absolute; left: calc(-12px * var(--s)); top: calc(-13px * var(--s));
  width: calc(50px * var(--s)); height: calc(50px * var(--s));
  background-repeat: no-repeat; image-rendering: pixelated; pointer-events: none;
}
:root[data-theme="dark"] #pet .spr { filter: drop-shadow(0 0 1px rgba(255, 255, 255, .45)); }
#pet .wrap { position: absolute; inset: 0; transform-origin: 50% 0; }
#pet.carried .wrap { animation: dangle .5s ease-in-out infinite alternate; }
#pet.wiggle .wrap { animation: wiggle .16s steps(2) infinite; }
#pet.zoom .wrap { animation: wiggle .1s steps(2) infinite; }
@keyframes dangle { from { transform: rotate(-8deg); } to { transform: rotate(8deg); } }
@keyframes wiggle { 50% { transform: translateX(calc(1px * var(--s))); } }

#bubble {
  font-size: 13px; color: var(--soft); opacity: 0; transition: opacity .3s; pointer-events: none;
  white-space: nowrap; display: flex; align-items: center; gap: 4px; z-index: 6000;
}
#bubble.on { opacity: 1; }
#toy { cursor: pointer; padding: 6px; }
.treat { pointer-events: none; animation: appear .3s ease-out; transition: transform .45s cubic-bezier(.2, .8, .3, 1); }
.gift { cursor: pointer; padding: 8px; animation: appear .3s ease-out, bob 1.6s ease-in-out infinite alternate; }
@keyframes appear { from { opacity: 0; } }
@keyframes bob { to { margin-top: -4px; } }
#fly { pointer-events: none; display: none; z-index: 5000; }
#fly.on { display: block; }
#fly svg { animation: flap .22s steps(2) infinite; }
#fly.rest svg { animation-duration: 1.4s; }
@keyframes flap { 50% { transform: scaleX(.35); } }
#laser {
  position: fixed; left: 0; top: 0; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; border-radius: 50%; z-index: 6001;
  background: #ff4d5e; box-shadow: 0 0 6px 2px rgba(255, 77, 94, .55); pointer-events: none; display: none;
}
#laser.on { display: block; }
.float { position: fixed; pointer-events: none; z-index: 6002; animation: rise 1.3s ease-out forwards; }
.float.z, .float.t { color: var(--soft); font-size: 12px; animation-duration: 2.2s; white-space: nowrap; }
.float.c { color: var(--gold); font-size: 13px; font-weight: 500; animation-duration: 1.6s; white-space: nowrap; display: flex; gap: 4px; align-items: center; }
@keyframes rise {
  from { opacity: 0; transform: translate(-50%, 0) scale(.6); }
  15% { opacity: 1; transform: translate(-50%, -10px) scale(1); }
  to { opacity: 0; transform: translate(calc(-50% + var(--dx, 0px)), -70px); }
}

/* ---- HUD ---- */
#hud {
  position: fixed; left: max(14px, env(safe-area-inset-left)); top: max(14px, env(safe-area-inset-top)); z-index: 7000;
  display: grid; gap: 6px; background: none; border: 0; padding: 4px; text-align: left; cursor: pointer;
}
#hud .coins { display: flex; align-items: center; gap: 6px; font-weight: 500; font-variant-numeric: tabular-nums; font-size: 14px; }
#hud .need { display: grid; grid-template-columns: 14px 58px; align-items: center; gap: 6px; }
#hud .bar { height: 5px; border-radius: 3px; background: var(--faint); overflow: hidden; }
#hud .bar i { display: block; height: 100%; border-radius: 3px; transition: width .6s; }
#hud .need.low .bar i { animation: low 1s ease-in-out infinite alternate; }
@keyframes low { to { opacity: .35; } }

.corner {
  position: fixed; width: 42px; height: 42px; border-radius: 50%; z-index: 7000;
  display: grid; place-items: center; border: 0; background: transparent; color: var(--soft);
  cursor: pointer; transition: color .2s, background .2s;
}
.corner:hover, .corner:focus-visible { color: var(--ink); background: var(--faint); outline: none; }
.corner svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.corner .dot { position: absolute; top: 8px; right: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); display: none; }
.corner.new .dot { display: block; }
#rank { right: max(10px, env(safe-area-inset-right)); top: max(10px, env(safe-area-inset-top)); }
#games { right: calc(max(10px, env(safe-area-inset-right)) + 42px); top: max(10px, env(safe-area-inset-top)); }
#tasks { right: calc(max(10px, env(safe-area-inset-right)) + 84px); top: max(10px, env(safe-area-inset-top)); }
#add { left: max(10px, env(safe-area-inset-left)); bottom: max(10px, env(safe-area-inset-bottom)); }
#sound { right: max(10px, env(safe-area-inset-right)); bottom: max(10px, env(safe-area-inset-bottom)); }
#sound .on, #sound[aria-pressed="true"] .off { display: none; }
#sound[aria-pressed="true"] .on { display: inline; }
#sound.missing { opacity: .35; }
#status {
  position: fixed; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 7000;
  background: none; border: 0; padding: 8px 14px; border-radius: 99px; cursor: pointer;
  color: var(--soft); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; transition: color .2s, background .2s;
}
#status:hover, #status:focus-visible { color: var(--ink); background: var(--faint); outline: none; }
#status b { font-weight: 500; color: var(--ink); margin-right: .6em; }

/* ---- toasts & first-visit tips ---- */
#toasts { position: fixed; left: 50%; top: max(64px, calc(env(safe-area-inset-top) + 54px)); transform: translateX(-50%); z-index: 7500; display: grid; gap: 6px; justify-items: center; pointer-events: none; }
.toast {
  background: var(--card); color: var(--ink); border-radius: 99px; padding: 8px 14px; font-size: 13px; white-space: nowrap;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .08); display: flex; gap: 8px; align-items: center; animation: toast 3.2s ease forwards;
}
.toast b { color: var(--gold); font-weight: 500; display: inline-flex; align-items: center; gap: 4px; }
@keyframes toast { 0% { opacity: 0; transform: translateY(-6px); } 8%, 85% { opacity: 1; transform: none; } 100% { opacity: 0; } }
#coach {
  position: fixed; left: 50%; bottom: calc(max(14px, env(safe-area-inset-bottom)) + 52px); transform: translateX(-50%); z-index: 7600;
  background: var(--ink); color: var(--bg); border-radius: 16px; padding: 10px 16px; font-size: 13px; text-align: center;
  display: none; max-width: calc(100vw - 32px); box-shadow: 0 6px 24px rgba(0, 0, 0, .15);
}
#coach.on { display: block; animation: appear .3s ease-out; }
#coach .step { opacity: .6; font-size: 11px; margin-bottom: 2px; }
#coach .skip { background: none; border: 0; color: inherit; opacity: .6; font-size: 11px; cursor: pointer; text-decoration: underline; margin-top: 4px; }

/* ---- sheets ---- */
.overlay {
  position: fixed; inset: 0; z-index: 8000; display: grid; place-items: center; padding: 16px;
  background: rgba(0, 0, 0, .14); opacity: 0; pointer-events: none; transition: opacity .25s;
}
.overlay.open { opacity: 1; pointer-events: auto; }
.card {
  width: min(100%, 380px); max-height: 86vh; overflow: auto; position: relative;
  background: var(--card); border-radius: 22px; padding: 22px 20px 18px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .1); transform: translateY(8px); transition: transform .25s;
  user-select: text; -webkit-user-select: text;
}
.overlay.open .card { transform: none; }
.card .x { position: absolute; right: 10px; top: 10px; width: 32px; height: 32px; border: 0; background: none; border-radius: 50%; color: var(--soft); font-size: 20px; cursor: pointer; }
.card .x:hover { background: var(--faint); color: var(--ink); }
.card h2 { margin: 0 0 4px; font-size: 16px; font-weight: 500; text-align: center; }
.card h3 { margin: 22px 0 10px; font-size: 11px; font-weight: 500; color: var(--soft); letter-spacing: .14em; text-transform: uppercase; text-align: center; }
.card .sub { text-align: center; color: var(--soft); font-size: 12px; margin: 0 0 16px; }
.tabs { display: flex; gap: 4px; justify-content: center; margin: 0 0 14px; }
.tabs button { border: 0; background: none; border-radius: 99px; padding: 6px 12px; font-size: 12px; color: var(--soft); cursor: pointer; }
.tabs button.on { background: var(--faint); color: var(--ink); }
.foot { margin-top: 22px; display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: center; font-size: 12px; color: var(--soft); }
.foot a { color: var(--soft); text-decoration: none; }
.foot a:hover { color: var(--ink); }
.field {
  width: 100%; background: var(--faint); border: 1px solid transparent; border-radius: 12px; color: var(--ink);
  font: inherit; font-size: 15px; padding: 10px 12px; outline: none;
}
.field:focus { border-color: var(--line); }
.field.code { letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }
.stack { display: grid; gap: 8px; }
.muted { color: var(--soft); font-size: 12px; text-align: center; }
.err { color: #c4574a; font-size: 12px; text-align: center; min-height: 16px; }
.sep { display: flex; align-items: center; gap: 10px; color: var(--soft); font-size: 11px; margin: 4px 0; }
.sep::before, .sep::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.switch { display: flex; justify-content: space-between; align-items: center; padding: 6px 2px; font-size: 13px; }
.switch input { appearance: none; width: 36px; height: 20px; border-radius: 99px; background: var(--line); position: relative; cursor: pointer; transition: background .2s; }
.switch input::after { content: ''; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--card); transition: left .2s; }
.switch input:checked { background: var(--ink); }
.switch input:checked::after { left: 18px; }
.seg { display: inline-flex; background: var(--faint); border-radius: 99px; padding: 2px; }
.seg button { border: 0; background: none; border-radius: 99px; padding: 4px 10px; font-size: 12px; color: var(--soft); cursor: pointer; }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }

.mini { display: inline-block; background-repeat: no-repeat; image-rendering: pixelated; vertical-align: middle; }
.mini.l { width: 52px; height: 38px; background-size: 1000px 100px; background-position: -24px -28px; }
.mini.s { width: 26px; height: 19px; background-size: 500px 50px; background-position: -12px -14px; }
#kinds { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
#kinds button { background: none; border: 0; padding: 10px 0; border-radius: 14px; cursor: pointer; opacity: .55; transition: opacity .2s, background .2s; }
#kinds button:hover { opacity: .85; }
#kinds button.on { opacity: 1; background: var(--faint); }
#kind-note { text-align: center; color: var(--soft); font-size: 12px; min-height: 18px; margin: 10px 0 14px; }
.name-row { display: flex; gap: 8px; justify-content: center; align-items: center; }
#name { width: 14ch; background: none; border: 0; border-bottom: 1.5px dashed var(--soft); color: var(--ink); font: inherit; font-size: 16px; text-align: center; padding: 4px 0; outline: none; }
#name::placeholder { color: var(--soft); }
#name-ok { background: none; border: 0; font-size: 18px; color: var(--soft); cursor: pointer; padding: 4px 8px; border-radius: 99px; }
#gifts { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; text-align: center; font-size: 11px; color: var(--soft); }
#gifts div { display: grid; justify-items: center; gap: 4px; }
#gifts .none svg { opacity: .18; filter: grayscale(1); }

.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tile {
  background: none; border: 1px solid transparent; border-radius: 14px; padding: 10px 4px 8px; cursor: pointer;
  display: grid; justify-items: center; align-content: end; gap: 6px; min-height: 112px; font-size: 11px; color: var(--soft); transition: background .2s;
}
.tile:hover { background: var(--faint); }
.tile.on { background: var(--faint); color: var(--ink); }
.tile .price { display: inline-flex; gap: 4px; align-items: center; color: var(--ink); font-weight: 500; }
.tile.poor .price { color: var(--soft); }
.tile.poor img, .tile.poor svg { opacity: .45; }

.task { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 10px 2px; border-bottom: 1px solid var(--line); font-size: 13px; }
.task:last-child { border-bottom: 0; }
.task .bar { grid-column: 1 / -1; height: 4px; background: var(--faint); border-radius: 2px; overflow: hidden; }
.task .bar i { display: block; height: 100%; background: var(--ink); border-radius: 2px; }
.task.done { color: var(--soft); }
.task.done .bar i { background: var(--soft); }
.task .r { display: inline-flex; gap: 4px; align-items: center; color: var(--gold); font-weight: 500; }
.streak { display: flex; gap: 6px; justify-content: center; margin: 4px 0 2px; }
.streak span { width: 26px; height: 26px; border-radius: 50%; background: var(--faint); display: grid; place-items: center; font-size: 11px; color: var(--soft); }
.streak span.on { background: var(--ink); color: var(--bg); }

.gamecard { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px; border-radius: 16px; background: var(--faint); margin-bottom: 8px; }
.gamecard p { margin: 0; font-size: 12px; color: var(--soft); }
.gamecard b { font-weight: 500; }

#list { list-style: none; margin: 0; padding: 0; min-height: 120px; }
#list li { display: grid; grid-template-columns: 2em auto 1fr auto; gap: 10px; align-items: center; padding: 6px 8px; border-radius: 10px; font-variant-numeric: tabular-nums; }
#list li .n, #list li .v { color: var(--soft); }
#list li.me { background: var(--faint); font-weight: 500; }
#list li.gap { display: block; text-align: center; color: var(--soft); padding: 0; }
#list .empty { text-align: center; color: var(--soft); padding: 12px; }

/* ---- mini-games ---- */
.game { position: fixed; inset: 0; z-index: 9000; background: var(--bg); touch-action: none; }
.game canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.game-bar { position: absolute; left: 0; right: 0; top: max(12px, env(safe-area-inset-top)); display: flex; justify-content: center; gap: 28px; font-size: 18px; font-weight: 500; font-variant-numeric: tabular-nums; z-index: 2; pointer-events: none; }
.game-time { color: var(--soft); }
.game-x { pointer-events: auto; position: fixed; right: 10px; top: max(8px, env(safe-area-inset-top)); width: 40px; height: 40px; border: 0; border-radius: 50%; background: none; color: var(--soft); font-size: 24px; cursor: pointer; }
.game-card { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(320px, calc(100vw - 32px)); background: var(--card); border-radius: 22px; padding: 22px; text-align: center; box-shadow: 0 10px 40px rgba(0, 0, 0, .1); z-index: 3; }
.game-card.hide { display: none; }
.game-card h2 { margin: 0 0 6px; font-size: 18px; font-weight: 500; }
.game-how { color: var(--soft); font-size: 13px; margin: 0 0 12px; }
.game-result { margin: 0 0 14px; font-size: 14px; min-height: 20px; }
.game-result b { font-size: 20px; }

@media (prefers-reduced-motion: reduce) {
  #pet .wrap, #fly svg, .gift, .item, .toast { animation: none !important; }
}

/* ---- litter & mess ---- */
.poop { cursor: pointer; padding: 14px 10px 0; }
.poop .stink { position: absolute; left: 50%; top: 0; transform: translateX(-50%); color: #9c8a5a; font-size: 14px; opacity: .6; animation: stink 1.6s ease-in-out infinite; pointer-events: none; }
@keyframes stink { 0% { transform: translate(-50%, 6px); opacity: 0; } 40% { opacity: .7; } 100% { transform: translate(-50%, -8px); opacity: 0; } }
#hud .need.mess { grid-template-columns: 14px auto; font-size: 11px; color: var(--soft); }
.tabs { flex-wrap: wrap; }
#badgelist { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.badge { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--soft); padding: 6px 8px; border-radius: 10px; background: var(--faint); opacity: .6; }
.badge span { color: var(--soft); }
.badge.on { opacity: 1; color: var(--ink); }
.badge.on span { color: var(--gold); }

/* ================= café ================= */
:root { --panel: 0px; }
@media (min-width: 900px) { :root { --panel: 320px; } #add { display: none; } }
#rank { right: calc(var(--panel) + max(10px, env(safe-area-inset-right))); }
#games { right: calc(var(--panel) + max(10px, env(safe-area-inset-right)) + 42px); }
#tasks { right: calc(var(--panel) + max(10px, env(safe-area-inset-right)) + 84px); }
#sound { right: calc(var(--panel) + max(10px, env(safe-area-inset-right))); }
#status, #toasts, #coach { left: calc((100vw - var(--panel)) / 2); }

/* the fish counter */
#bank {
  position: fixed; top: max(12px, env(safe-area-inset-top)); left: calc((100vw - var(--panel)) / 2); transform: translateX(-50%);
  z-index: 7000; text-align: center; pointer-events: none; white-space: nowrap;
}
#bank .bank-fish { display: inline-flex; align-items: center; gap: 8px; font-size: 30px; font-weight: 500; font-variant-numeric: tabular-nums; letter-spacing: .01em; }
#bank .bank-fps { font-size: 12px; color: var(--soft); margin-top: -2px; font-variant-numeric: tabular-nums; }
#bank .bank-fish.bump { animation: bankbump .18s ease-out; }
#bank.shake { animation: bankshake .3s steps(3); }
@keyframes bankbump { 40% { transform: scale(1.08); } }
@keyframes bankshake { 33% { transform: translate(calc(-50% - 4px), 2px); } 66% { transform: translate(calc(-50% + 4px), -2px); } }
#combo { font-size: 12px; color: var(--accent); height: 0; opacity: 0; transition: opacity .2s; }
#combo.on { opacity: 1; height: auto; }
#combo b { font-size: 15px; }
#buffs { display: flex; gap: 6px; justify-content: center; margin-top: 4px; }
#buffs span { font-size: 11px; color: #7a5a1a; background: #f6dd9a; border-radius: 99px; padding: 2px 8px; animation: glow 1s ease-in-out infinite alternate; }
@keyframes glow { to { box-shadow: 0 0 10px rgba(242, 193, 78, .7); } }
@media (max-width: 899px) { #hud { top: max(70px, calc(env(safe-area-inset-top) + 64px)); } #bank .bank-fish { font-size: 24px; } }
#toasts { top: max(86px, calc(env(safe-area-inset-top) + 80px)); }

/* tap juice */
.pop {
  position: fixed; z-index: 6500; pointer-events: none; transform: translate(-50%, -50%);
  font-weight: 500; font-size: 17px; color: var(--ink); text-shadow: 0 1px 0 var(--bg), 0 0 6px var(--bg);
  animation: popup .9s cubic-bezier(.2, .8, .3, 1) forwards; font-variant-numeric: tabular-nums;
}
.pop.crit { font-size: 26px; color: #d98a2b; }
.pop.word { font-size: 15px; color: var(--accent); animation-duration: 1.2s; }
.pop.word.gold { color: #d98a2b; font-size: 18px; }
@keyframes popup {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(.6); }
  15% { opacity: 1; transform: translate(-50%, -60%) scale(1.15); }
  30% { transform: translate(-50%, -70%) scale(1); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx, 0px)), -260%); }
}
.bit { position: fixed; z-index: 6400; pointer-events: none; animation: bit .7s cubic-bezier(.2, .7, .4, 1) forwards; }
@keyframes bit { from { transform: translate(-50%, -50%); opacity: 1; } to { transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))); opacity: 0; } }

/* extra cats share the main cat's sprite setup */
.npc { width: calc(26px * var(--s)); height: calc(20px * var(--s)); cursor: pointer; touch-action: none; }
.npc::after {
  content: ''; position: absolute; left: 50%; bottom: calc(-1.5px * var(--s));
  width: calc(18px * var(--s)); height: calc(3px * var(--s)); transform: translateX(-50%);
  background: var(--shadow); border-radius: 50%; z-index: -1;
}
.npc .wrap { position: absolute; inset: 0; transform-origin: 50% 100%; }
.npc .spr {
  position: absolute; left: calc(-12px * var(--s)); top: calc(-13px * var(--s));
  width: calc(50px * var(--s)); height: calc(50px * var(--s));
  background-repeat: no-repeat; image-rendering: pixelated; pointer-events: none;
}
:root[data-theme="dark"] .npc .spr { filter: drop-shadow(0 0 1px rgba(255, 255, 255, .45)); }
.npc.golden .spr { filter: sepia(1) saturate(5) hue-rotate(-8deg) brightness(1.15) drop-shadow(0 0 4px rgba(255, 200, 60, .9)); }
.npc.squish .wrap, #pet.squish .wrap { animation: squish .22s ease-out; }
@keyframes squish { 30% { transform: scale(1.12, .86); } 60% { transform: scale(.95, 1.06); } }

/* the shop panel: docked on wide screens, a bottom sheet on phones */
#store {
  position: fixed; z-index: 7200; background: var(--card); display: flex; flex-direction: column; overflow: hidden;
  right: 0; top: 0; bottom: 0; width: 320px; border-left: 1px solid var(--line);
}
#store .x { display: none; }
#store-scrim { display: none; }
@media (max-width: 899px) {
  #store {
    top: auto; left: 0; width: auto; height: min(70vh, 560px); border-left: 0; border-radius: 22px 22px 0 0;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, .12); transform: translateY(105%); transition: transform .28s cubic-bezier(.2, .8, .3, 1);
  }
  #store.open { transform: none; }
  #store .x { display: block; position: absolute; right: 10px; top: 8px; width: 32px; height: 32px; border: 0; background: none; color: var(--soft); font-size: 20px; cursor: pointer; z-index: 2; }
  #store-scrim { display: block; position: fixed; inset: 0; z-index: 7100; background: rgba(0, 0, 0, .12); opacity: 0; pointer-events: none; transition: opacity .25s; }
  #store.open + #store-scrim, #store-scrim.on { opacity: 1; pointer-events: auto; }
}
.store-tabs { display: flex; gap: 4px; padding: 14px 14px 8px; }
.store-tabs button { flex: 1; border: 0; background: none; border-radius: 99px; padding: 8px 6px; font-size: 13px; color: var(--soft); cursor: pointer; }
.store-tabs button.on { background: var(--faint); color: var(--ink); font-weight: 500; }
.store-tabs i { font-style: normal; font-size: 10px; background: var(--accent); color: #fff; border-radius: 99px; padding: 0 5px; margin-left: 2px; }
.store-tabs i:empty { display: none; }
.store-mode { display: flex; gap: 4px; justify-content: flex-end; padding: 0 14px 6px; }
.store-mode[hidden] { display: none; }
.store-mode button { border: 1px solid var(--line); background: none; border-radius: 99px; padding: 2px 10px; font-size: 11px; color: var(--soft); cursor: pointer; }
.store-mode button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
#store-list, #store-things { flex: 1; overflow: auto; padding: 0 10px 14px; }
#store-list[hidden], #store-things[hidden] { display: none; }
#store-things { padding: 0 14px 14px; }
.row {
  width: 100%; display: grid; grid-template-columns: 58px 1fr auto; gap: 10px; align-items: center; text-align: left;
  border: 0; background: none; border-radius: 14px; padding: 8px; cursor: pointer; margin-bottom: 2px; transition: background .15s;
}
.row:hover { background: var(--faint); }
.row .ic { display: grid; place-items: center; height: 44px; }
.row .nm { display: grid; line-height: 1.25; }
.row .nm b { font-weight: 500; font-size: 14px; }
.row .nm small { color: var(--soft); font-size: 11px; }
.row .pr { display: inline-flex; gap: 4px; align-items: center; font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row.poor { opacity: .45; }
.row.locked { opacity: .35; cursor: default; }
.row.locked .ic { font-size: 22px; color: var(--soft); }
.row.yay { animation: yay .3s ease-out; }
.row.nope { animation: nope .25s steps(4); }
@keyframes yay { 40% { background: rgba(242, 193, 78, .3); transform: scale(1.02); } }
@keyframes nope { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
.newcafe { margin-top: 14px; padding: 12px; border-radius: 14px; background: var(--faint); font-size: 12px; text-align: center; }
.newcafe p { margin: 0 0 8px; }
#store .muted { padding: 8px; }
.npc.wiggle .wrap { animation: wiggle .16s steps(2) infinite; }

/* ================= pure clicker layout: shop on the left, big cat, hero ================= */
:root { --panel: 300px; }
:root[data-side="closed"] { --panel: 0px; }
#side {
  position: fixed; left: 0; top: 0; bottom: 0; width: 300px; z-index: 7200;
  background: var(--card); border-right: 1px solid var(--line); display: flex; flex-direction: column;
  transform: translateX(calc(var(--panel) - 300px)); transition: transform .25s cubic-bezier(.2, .8, .3, 1);
}
#side-handle {
  position: absolute; right: -26px; top: 50%; width: 26px; height: 72px; transform: translateY(-50%);
  border: 1px solid var(--line); border-left: 0; border-radius: 0 12px 12px 0; background: var(--card); cursor: pointer; display: grid; place-items: center;
}
#side-handle span { width: 8px; height: 8px; border-right: 2px solid var(--soft); border-bottom: 2px solid var(--soft); transform: rotate(135deg) translate(-1px, 1px); transition: transform .25s; }
:root[data-side="closed"] #side-handle span { transform: rotate(-45deg) translate(1px, -1px); }
.side-head { padding: 12px 12px 6px; }
.store-tabs button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.store-tabs svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.store-mode { padding: 6px 2px 0; }
#store-list { flex: 1; overflow: auto; padding: 4px 8px 10px; }
.row .nm small.eta { color: var(--accent); }
.row.on { background: rgba(242, 193, 78, .14); }
.side-foot { border-top: 1px solid var(--line); padding: 10px 12px; display: grid; gap: 8px; }
.side-icons { display: flex; justify-content: space-between; }
#side .icon {
  position: static; width: 40px; height: 40px; border-radius: 50%; border: 0; background: none; color: var(--soft); cursor: pointer;
  display: grid; place-items: center; transform: none; padding: 0;
}
#side .icon:hover, #side .icon:focus-visible { color: var(--ink); background: var(--faint); outline: none; }
#side .icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#side .icon .dot { position: absolute; margin: -22px 0 0 20px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); display: none; }
#side .icon.new .dot { display: block; }
#side .steam { font-size: 11px; color: var(--soft); text-decoration: none; text-align: center; padding: 6px; border-radius: 99px; background: var(--faint); }
#side .steam:hover { color: var(--ink); }
.stars { display: grid; gap: 4px; font-size: 11px; color: var(--soft); }
.stars[hidden] { display: none; }
.stars .bar { height: 4px; background: var(--faint); border-radius: 2px; overflow: hidden; }
.stars .bar i { display: block; height: 100%; background: var(--gold); }
.stars .link { font-size: 11px; color: var(--gold); }

/* the counter sits over the middle of the room */
#bank { left: calc(var(--panel) + (100vw - var(--panel)) / 2); }
#toasts, #coach { left: calc(var(--panel) + (100vw - var(--panel)) / 2); }
#bank .bank-fish { font-size: 38px; font-weight: 800; }
#bank .bank-fps .mood { margin-left: 8px; color: var(--ink); }
#bank .bank-fps .st { margin-left: 8px; color: var(--gold); }
.next { display: grid; grid-template-columns: 120px auto; gap: 8px; align-items: center; margin: 4px auto 0; font-size: 11px; color: var(--soft); justify-content: center; }
.next[hidden] { display: none; }
.next .bar { height: 4px; background: var(--faint); border-radius: 2px; overflow: hidden; }
.next .bar i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.next.bump { animation: bankbump .3s ease-out; }
#buffs span.tuna { background: #cfe0f0; color: #3b5a7a; }
#buffs span.catnip { background: #cfe8c6; color: #3f6a35; }
#buffs span.brush { background: #f3d6dc; color: #7a3f4f; }

/* juice */
.flyfish { position: fixed; z-index: 6300; pointer-events: none; animation: flyfish .7s cubic-bezier(.3, 0, .6, 1) forwards; }
@keyframes flyfish { 0% { transform: translate(-50%, -50%) scale(1); opacity: 1; } 100% { transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(.6); opacity: .2; } }
body.pulse::before { content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 1; background: radial-gradient(circle at 50% 60%, rgba(242, 193, 78, .22), transparent 60%); animation: pulse .5s ease-out forwards; }
@keyframes pulse { from { opacity: 1; } to { opacity: 0; } }
.item.wobble, .item-front.wobble { animation: wobble .6s ease-in-out infinite; }
@keyframes wobble { 0%, 100% { margin-left: 0; } 25% { margin-left: calc(1px * var(--s)); } 75% { margin-left: calc(-1px * var(--s)); } }
.grid6 { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; justify-items: center; }
.grid6 .none { opacity: .2; filter: grayscale(1); }

/* phones: the room is full width and the shop is a drawer */
@media (max-width: 899px) {
  :root { --panel: 0px; }
  #side { width: min(300px, 86vw); transform: translateX(-102%); box-shadow: none; }
  :root[data-side="open"] #side { transform: none; box-shadow: 10px 0 40px rgba(0, 0, 0, .15); }
  #bank .bank-fish { font-size: 28px; }
}

/* hero: the first thing a new visitor sees */
#hero { position: fixed; inset: 0; z-index: 9500; display: grid; place-items: center; padding: 20px; background: var(--bg); overflow: auto; transition: opacity .4s, transform .4s; }
#hero[hidden] { display: none; }
#hero.out { opacity: 0; transform: scale(1.04); pointer-events: none; }
.hero-card { max-width: 560px; text-align: center; }
.hero-cat { display: inline-block; width: 150px; height: 150px; margin-bottom: 6px; }
.hero-cat .spr { width: 150px; height: 150px; background-size: 1500px 150px; image-rendering: pixelated; animation: heroidle 1.4s steps(10) infinite; }
@keyframes heroidle { to { background-position: -1500px 0; } }
#hero h1 { font-size: 64px; font-weight: 800; margin: 0; letter-spacing: -.02em; line-height: 1; }
#hero .tag { margin: 6px 0 18px; color: var(--soft); font-size: 16px; letter-spacing: .12em; text-transform: uppercase; }
#hero .pitch { font-size: 17px; line-height: 1.55; margin: 0 0 24px; }
.hero-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 26px; }
.btn.big { padding: 13px 24px; font-size: 15px; text-decoration: none; }
.hero-feats { list-style: none; padding: 0; margin: 0 auto 22px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; text-align: left; font-size: 13px; color: var(--soft); max-width: 480px; }
.hero-feats li::before { content: '♥ '; color: var(--accent); }
.hero-foot { font-size: 12px; color: var(--soft); }
.hero-foot a { color: var(--soft); }
@media (max-width: 520px) { #hero h1 { font-size: 48px; } .hero-feats { grid-template-columns: 1fr; } }

.me-line { font-size: 12px; color: var(--soft); text-align: center; }
.me-line b { color: var(--ink); font-weight: 500; }
#status.new .dot { display: block; }

/* helpers' extra copies on the floor (yarn, mugs, posts…): tappable, not draggable */
.decor { cursor: grab; touch-action: none; }
.decor.dragging { cursor: grabbing; z-index: 5500 !important; }
.decor.dragging img { filter: drop-shadow(0 6px 4px rgba(0, 0, 0, .18)); }
.decor img { display: block; }
.decor.pop { animation: pop .3s ease-out; }
.decor.squish img { animation: squish .22s ease-out; transform-origin: 50% 100%; }
:root[data-theme="dark"] .decor img { filter: brightness(.72) saturate(.85); }
